Skip to content

Commit 92b3a75

Browse files
shufpsWantClue
andauthored
keep config checkbox to skip nvs partition (#15)
* keep config checkbox to skip nvs partition * make keep config default true * add missing type annotation * fixed * fix: update keepConfig default to false --------- Co-authored-by: WantClue <[email protected]>
1 parent 5168f60 commit 92b3a75

File tree

10 files changed

+62
-13
lines changed

10 files changed

+62
-13
lines changed

src/components/LandingHero.tsx

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default function LandingHero() {
3232
const textDecoderRef = useRef<TextDecoderStream | null>(null)
3333
const readableStreamClosedRef = useRef<Promise<void> | null>(null)
3434
const logsRef = useRef<string>('')
35+
const [keepConfig, setKeepConfig] = useState(false);
3536

3637
useEffect(() => {
3738
const userAgent = navigator.userAgent.toLowerCase();
@@ -116,6 +117,10 @@ export default function LandingHero() {
116117
}
117118
}
118119

120+
const handleKeepConfigToggle = (event: React.ChangeEvent<HTMLInputElement>) => {
121+
setKeepConfig(event.target.checked);
122+
};
123+
119124
const startSerialLogging = async () => {
120125
if (!serialPortRef.current) {
121126
setStatus(t('status.connectFirst'));
@@ -256,11 +261,34 @@ export default function LandingHero() {
256261

257262
setStatus(t('status.flashing', { percent: 0 }))
258263

264+
// On all Bitaxe derivatives the same
265+
const nvsStart = 0x9000;
266+
const nvsSize = 0x6000;
267+
268+
let parts;
269+
270+
if (keepConfig) {
271+
parts = [
272+
{
273+
data: firmwareBinaryString.slice(0, nvsStart), // Data before NVS
274+
address: 0,
275+
},
276+
{
277+
data: firmwareBinaryString.slice(nvsStart + nvsSize), // Data after NVS
278+
address: nvsStart + nvsSize,
279+
},
280+
];
281+
} else {
282+
parts = [
283+
{
284+
data: firmwareBinaryString, // Entire firmware binary
285+
address: 0,
286+
},
287+
];
288+
}
289+
259290
await loader.writeFlash({
260-
fileArray: [{
261-
data: firmwareBinaryString,
262-
address: 0
263-
}],
291+
fileArray: parts,
264292
flashSize: "keep",
265293
flashMode: "keep",
266294
flashFreq: "keep",
@@ -354,6 +382,18 @@ export default function LandingHero() {
354382
disabled={isConnecting || isFlashing}
355383
/>
356384
)}
385+
<div className="flex items-center gap-2">
386+
<input
387+
type="checkbox"
388+
id="keepConfig"
389+
className="cursor-pointer"
390+
checked={keepConfig}
391+
onChange={handleKeepConfigToggle}
392+
/>
393+
<label htmlFor="keepConfig" className="text-gray-500 dark:text-gray-400 cursor-pointer">
394+
{t('hero.keepConfig')}
395+
</label>
396+
</div>
357397
<Button
358398
className="w-full"
359399
onClick={handleStartFlashing}

src/i18n/locales/de.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"startLogging": "Logging starten",
2525
"stopLogging": "Logging stoppen",
2626
"downloadLogs": "Logs herunterladen",
27-
"loggingDescription": "Verbinde dein Gerät, protokolliere die seriellen Daten und lade diese später herunter."
27+
"loggingDescription": "Verbinde dein Gerät, protokolliere die seriellen Daten und lade diese später herunter.",
28+
"keepConfig": "Konfiguration behalten"
2829
},
2930
"features": {
3031
"title": "Funktionen",

src/i18n/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"startLogging": "Start Logging",
2525
"stopLogging": "Stop Logging",
2626
"downloadLogs": "Download Logs",
27-
"loggingDescription": "Connect your device, log the serial data and download it later on."
27+
"loggingDescription": "Connect your device, log the serial data and download it later on.",
28+
"keepConfig": "Keep configuration"
2829
},
2930
"features": {
3031
"title": "Key Features",

src/i18n/locales/it.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"startLogging": "Avvia registrazione Log",
2525
"stopLogging": "Ferma registrazione Log",
2626
"downloadLogs": "Scarica Log",
27-
"loggingDescription": "Collega il tuo dispositivo, registra i dati seriali e scaricali successivamente."
27+
"loggingDescription": "Collega il tuo dispositivo, registra i dati seriali e scaricali successivamente.",
28+
"keepConfig": "Mantieni configurazione"
2829
},
2930
"features": {
3031
"title": "Caratteristiche principali",

src/i18n/locales/pt.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"startLogging": "Iniciar Log",
2525
"stopLogging": "Parar Log",
2626
"downloadLogs": "Baixar Logs",
27-
"loggingDescription": "Conecte seu dispositivo, registre os dados seriais e baixe-os posteriormente."
27+
"loggingDescription": "Conecte seu dispositivo, registre os dados seriais e baixe-os posteriormente.",
28+
"keepConfig": "Manter configuração"
2829
},
2930
"features": {
3031
"title": "Principais Recursos",

src/i18n/locales/ro.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"startLogging": "Pornește logarea",
2525
"stopLogging": "Oprește logarea",
2626
"downloadLogs": "Descarcă loguri",
27-
"loggingDescription": "Conectează aparatul, înregistrează datele de pe comunicarea serială și descarcă mai târziu."
27+
"loggingDescription": "Conectează aparatul, înregistrează datele de pe comunicarea serială și descarcă mai târziu.",
28+
"keepConfig": "Păstrează configurația"
2829
},
2930
"features": {
3031
"title": "Funcții importante",

src/i18n/locales/ru.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"startLogging": "Начать ведение журнала",
2525
"stopLogging": "Остановить ведение журнала",
2626
"downloadLogs": "Скачать логи",
27-
"loggingDescription": "Подключи свое устройство, запиши в журнал последовательные данные и загрузи их позже."
27+
"loggingDescription": "Подключи свое устройство, запиши в журнал последовательные данные и загрузи их позже.",
28+
"keepConfig": "Сохранить конфигурацию"
2829
},
2930
"features": {
3031
"title": "Ключевые особенности",

src/i18n/locales/sk.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"startLogging": "Spustiť Logovanie",
2525
"stopLogging": "Ukončiť Logovanie",
2626
"downloadLogs": "Stiahniť Logy",
27-
"loggingDescription": "Pripojte Vaše zariadenie, uložte serialové dáta a stiahnite ich neskôr."
27+
"loggingDescription": "Pripojte Vaše zariadenie, uložte serialové dáta a stiahnite ich neskôr.",
28+
"keepConfig": "Zachovať konfiguráciu"
2829
},
2930
"features": {
3031
"title": "Kľučové Funkcie",

src/i18n/locales/tlh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"startLogging": "De' ghItlhchoH",
2525
"stopLogging": "De' ghoSchoH",
2626
"downloadLogs": "De' nIH",
27-
"loggingDescription": "chel jan, ghItlh De', nIH 'ach neH le'vaD."
27+
"loggingDescription": "chel jan, ghItlh De', nIH 'ach neH le'vaD.",
28+
"keepConfig": "nugh rI' choq"
2829
},
2930
"features": {
3031
"title": "nIvmo' chutmey",

src/i18n/locales/tr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"startLogging": "Loglamaya Başla",
2525
"stopLogging": "Loglamayı Durdur",
2626
"downloadLogs": "Logu İndir",
27-
"loggingDescription": "Cihazınızı seçin, işlemi loglayın ve daha sonra indirin."
27+
"loggingDescription": "Cihazınızı seçin, işlemi loglayın ve daha sonra indirin.",
28+
"keepConfig": "Yapılandırmayı koru"
2829
},
2930
"features": {
3031
"title": "Öne Çıkan Özellikler",

0 commit comments

Comments
 (0)