Help please! Where am I going wrong?
Hugh
Posts: 362
Sorry folks, another episode of me being as thick as two short planks...
I have a protoboard to which a Parallax 27977 LCD, three LEDs and three switches are attached. The LEDs and switches work (i.e., I can control whether the LEDs are on or off, and the switch monitoring is OK (I've displayed their state on the LCD))
All I want to do is monitor one of the switches and move between three states that I have named Mode1, Mode2 and (wait for it!) Mode3. The 'mode' switch increments the mode 1, 2, 3, 1, 2, etc., correctly, as shown by debugging to the LCD.
In each state there will be some similar code (setting the LED, adding a title and doing 'stuff' before returning to the main PUB to see if).
What is driving me mad? In the attached code I added a variable 'oldMode', the purpose being that when periodically checked, if the current value of 'Mode' didn't correlate with 'oldMode', the correct 'mode' code would be called and 'oldMode' would be updated.
i) Looking at 'oldMode' as printed to the LCD it toggles 0, 1, 255, 0, 1, 255, etc.,
ii) The code only works with a StackSW of 10 bytes: 10 Longs and it stops working; 20 bytes and it stops working;
iii) The LCD is soooooo s l o w and keeps tripping over itself. Even though I have added a wait period after the 'cls' procedure it only sometimes clears and writes in the top left hand corner of the LCD. Other times it just keeps concatenating the title text sent to it. The baud rate is correct and it is getting 5V; I have double-checked the constatnts in Serial_Lcd against the manual.
iv) Declaring an additional variable (even if it is not referenced in a PUB) changes the behaviour of the code.
I have been through the objects looking for similarly-named variables, there is oodles of variable-space...
Any suggestions would be gratefully received!
Thanks
Hugh
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hugh - the thinking woman's Geoffrey Pyke.
I have a protoboard to which a Parallax 27977 LCD, three LEDs and three switches are attached. The LEDs and switches work (i.e., I can control whether the LEDs are on or off, and the switch monitoring is OK (I've displayed their state on the LCD))
All I want to do is monitor one of the switches and move between three states that I have named Mode1, Mode2 and (wait for it!) Mode3. The 'mode' switch increments the mode 1, 2, 3, 1, 2, etc., correctly, as shown by debugging to the LCD.
In each state there will be some similar code (setting the LED, adding a title and doing 'stuff' before returning to the main PUB to see if).
What is driving me mad? In the attached code I added a variable 'oldMode', the purpose being that when periodically checked, if the current value of 'Mode' didn't correlate with 'oldMode', the correct 'mode' code would be called and 'oldMode' would be updated.
i) Looking at 'oldMode' as printed to the LCD it toggles 0, 1, 255, 0, 1, 255, etc.,
ii) The code only works with a StackSW of 10 bytes: 10 Longs and it stops working; 20 bytes and it stops working;
iii) The LCD is soooooo s l o w and keeps tripping over itself. Even though I have added a wait period after the 'cls' procedure it only sometimes clears and writes in the top left hand corner of the LCD. Other times it just keeps concatenating the title text sent to it. The baud rate is correct and it is getting 5V; I have double-checked the constatnts in Serial_Lcd against the manual.
iv) Declaring an additional variable (even if it is not referenced in a PUB) changes the behaviour of the code.
I have been through the objects looking for similarly-named variables, there is oodles of variable-space...
Any suggestions would be gratefully received!
Thanks
Hugh
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hugh - the thinking woman's Geoffrey Pyke.
Comments
I would start with a stack area declared as "long stackSW[noparse][[/noparse] 20 ]"
Starting a project from scratch I seem to forget previous lessons-learned!
Thanks
Hugh
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hugh - the thinking woman's Geoffrey Pyke.