]> bicyclesonthemoon.info Git - klavirko/ui/commitdiff
limit voice storage to 250 pages.
authorb <rowerynaksiezycu@gmail.com>
Sat, 28 Dec 2024 13:02:07 +0000 (14:02 +0100)
committerb <rowerynaksiezycu@gmail.com>
Sat, 28 Dec 2024 13:02:07 +0000 (14:02 +0100)
fs.c
fs.h
gui.c

diff --git a/fs.c b/fs.c
index 1dbfa2dabaee103aaa0ae8b4ec0b6c06feb0d665..460e42813ca7cd61916048b792dc6b61759257ef 100644 (file)
--- 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 0a1871faaf8f59c820b8d0d0e4e3756a4ca9b86f..885d6ee5a1f5cad1333b46824546b8c6db3d3f2d 100644 (file)
--- 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 1d837e7bc6510042746fd8123a1a886cab612e57..513c62c6c38eab644ddf23ae855138d8ac40af61 100644 (file)
--- 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();
        }