B4R Question Arduino Mega stack problem

Mostez

Well-Known Member
Licensed User
Longtime User
Hello,
I wrote code for arduino mega with 3 menu selections, each menu has 4 items. Each sub routine of them includes this select statement to branch according to keypad press.

B4X:
private Sub MenuDBfiles(KeyFromMenuHandler As String)
    MenuIndex = MENU_DB_FILES
    If KeyFromMenuHandler = KEY_NONE  Then
        Clear
        PutString(0,0,"UPLOAD DBF",FontArial8x16,True)
        PutString (0,2,"1- Daily",FontArial5x8,False)
        PutString (0,3,"2- Monthly",FontArial5x8,False)
        PutString (0,4,"3- Archive",FontArial5x8,False)
        'PutString (0,5,"#- Cancel",FontArial5x8,False)
    End If
   
    Select KeyFromMenuHandler
        Case "1"
            UploadDailyDBF(KEY_NONE)
        Case "2"
            UploadMonthlyDBF(KEY_NONE)
        Case "3"
            UploadArchive(KEY_NONE)
        Case "#"
            Clear
            MainMenu(KEY_NONE)
            Return
    End Select

End Sub


The problem is before adding this menu part the code ran very well, but now it stops at start up and sometimes with array index error, when i comment some of these routines it runs OK, i tried to expand StackBufferSize to 1000 without any success!

is there a solution for this nesting or stacking problem?

NOTE: the code consumed 25% of code space and 50% of memory space
Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Mostez

Well-Known Member
Licensed User
Longtime User
Does it work properly if you make the font arrays much smaller
i did not try it yet, i will try it and let you know. the strange thing is, it is 50% of memory space, and the program runs abnormal :(
 
Upvote 0

Mostez

Well-Known Member
Licensed User
Longtime User
yes Erel, it worked perfectly, reduced from 61% to 37%

I don't know really how to thank you.. thanks so much
 
Upvote 0
Top