From 555aee87b53347bd74d7f30196c029005ff1e3d0 Mon Sep 17 00:00:00 2001 From: b Date: Sat, 28 Dec 2024 14:02:07 +0100 Subject: [PATCH] limit voice storage to 250 pages. --- fs.c | 8 +++++++- fs.h | 8 +++++--- gui.c | 30 +++++++++++++++++++++++++----- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/fs.c b/fs.c index 1dbfa2d..460e428 100644 --- a/fs.c +++ b/fs.c @@ -1,6 +1,6 @@ /* STORAGE OF SETTINGS */ /* -Copyright 2021 Balthasar Szczepański +Copyright 2021, 2024 Balthasar Szczepański Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -804,6 +804,12 @@ void fs_load_page (const uint8_t new_page) // debug_string("FS LOAD PAGE\r\n",1); + if (new_page >= N_PAGES) + { + // debug_string("wrong page ID\r\n",1); + return; + } + if (new_page == fs_page) { // debug_string("no change\r\n",1); diff --git a/fs.h b/fs.h index 0a1871f..885d6ee 100644 --- a/fs.h +++ b/fs.h @@ -1,6 +1,6 @@ /* STORAGE OF SETTINGS */ /* -Copyright 2021 Balthasar Szczepański +Copyright 2021, 2024 Balthasar Szczepański Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -261,7 +261,7 @@ AB: */ #define N_SECTORS 256 -#define N_PAGES 256 +#define N_PAGES 250 #define N_FILES_IN_SECTOR 8 #define N_FILES_ON_PAGE 6 #define N_INDEX_RECORDS 170 @@ -275,7 +275,7 @@ AB: /* This is a tradeoff between efficiency of memory space usage and frequency of defragmentation. With bigger value we're erasing and relocating less often, -which extends the life of the flash memorym +which extends the life of the flash memory, but we are wasting more space for deleted files. With the value of 2, even in the worst case, where each sector contains 2 deleted files we still have place for (8-2)*256=1536 files, @@ -297,6 +297,8 @@ Wait for it. ETAA: How about limit the number of pages to 250, which gives 1500 settings only? + +ETAAA: Yes, we go with 250 pages now. */ #define RECORD_OFFSET_ID 0 diff --git a/gui.c b/gui.c index 1d837e7..513c62c 100644 --- a/gui.c +++ b/gui.c @@ -1,6 +1,6 @@ /* GUI */ /* -Copyright 2021, 2022 Balthasar Szczepański +Copyright 2021, 2022, 2024 Balthasar Szczepański Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -477,9 +477,19 @@ inline void gui_event_select (const uint16_t event) else if((event & EVENT_BITS) == EVENT_JOG) { if ((event & ~EVENT_BITS) == JOG_PLUS) - ++gui_page; + { + if (gui_page < (N_PAGES - 1)) + ++gui_page; + else + gui_page = 0; + } else - --gui_page; + { + if (gui_page > 0) + --gui_page; + else + gui_page = N_PAGES - 1; + } draw_select(); reject_gui_events(); } @@ -691,9 +701,19 @@ inline void gui_event_select_save (const uint16_t event) else if((event & EVENT_BITS) == EVENT_JOG) { if ((event & ~EVENT_BITS) == JOG_PLUS) - ++gui_page; + { + if (gui_page < (N_PAGES - 1)) + ++gui_page; + else + gui_page = 0; + } else - --gui_page; + { + if (gui_page > 0) + --gui_page; + else + gui_page = N_PAGES - 1; + } draw_select_save(); reject_gui_events(); } -- 2.30.2