![]() |
Forum Index : Microcontroller and PC projects : Newie got a few questions
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10224 |
Have a look at Geoff's example code page 36 of the Micromite Plus addendum. Load this and run it and then make some changes to see how it all fits together |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Thanks, got that working fine, now to figure out why the other wasn't |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
ok - now this is going to get interesting As you all know from now, apart from me being a right pain in the rear end asking so many questions and asking for help I've figured out the switch routines, my problem was I was reading the 5.2 manual and not the 5.2 addend Can anyone give me any pointers on doing this section please? Specifically the restore and disable sections Am I right in assuming the GUI Restore is what's normally on the screen BEFORE the switch is pressed? and the GUI Disable is what's on the screen AFTER the switch is pressed? Obviously I have to tell the program what to display on each setting, buT i need to know if I'm on the right path to working it out, or if I'm thinking wronglt. [code]Sub TouchDown Select Case Touch(REF) ' find out the control touched Case sw1 ' the Weather/Forecast switch If CtrlVal(sw1) = 1 Then GUI Restore 'CLS then do the Colour RGB(white), RGB(black), and GUI forecast Sections from above - *** as a sub?? *** Else GUI Disable ' DO THE MAIN CLOCK/timing/serialport/picture routines here *not sure how to do this EndIf End Select End Sub[/code] |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Why doesn't this work? and is there a way to get it working? GUI SETUP 1 LOAD IMAGE sky1.bmp , 392 , 185 [quote]Load IMAGE sky1.bmp , 392 , 185 Error: Expected a string[/quote] If I try pic = Sky1.bmp and LOAD IMAGE PIC$ the error is Error: PIC already declared |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Option Explicit not set? [Code]new > pic=sky.bmp > print pic 0 > Print pic$ Error: PIC already declared > [/code] |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
[Code]> new > option explicit > Dim Pic as String > pic=sky.bmp Error: SKY.BMP not declared > pic="sky.bmp" > print pic sky.bmp > [/code] |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Thanks Phil I actually tried it without the OPTION EXPLICIT as errors in dim statements "should" have been ignored Just tried it WITH OPTION EXPLICIT and It just wont work. I "THINK" it's because I want to use it as part of GUI SETUP and I think that only certain functions like touch switches and so on work with that but there must be a way to load a picture as part of GUI SETUP 1 or GUI SETUP 2? |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
How big is the BMP? Can it be posted? 800x480 Screen? |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2932 |
PIC$="Sky1.bmp"
LOAD IMAGE PIC$ However, as I said yesterday, this will not 'keep' the image on Page 1 only as LOAD IMAGE is not an advanced GUI control (and PAGExx 'looks after' GUI controls only) |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
The image is 800 X 480 and yes it could be posted Thats a shame Phil, WHat I'd like to do with the gui controls is switch between 2 images, that way I can keep the clock on the screen all the time I'm going to have to figure a different way to do this somehow Here's the 2 images ![]() and when the button is pressed to go to the 2nd screen it's just this The clock is the same size and would go in the same place as the clock on the other picture ![]() |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2932 |
Peter did a recent post about Page switching allowing the images to be drawn onto each page, and then a quick switch between pages. From memory this was a C Function/Sub and I am not sure how 'integrated' it is with MMBasic OR whether it is a pure C Function. Either way it is worth looking at his code. WW |
||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Might be able to mix the Basic & Advanced graphics. But then again, you could just switch by an touch to a defined region of the screen; No Advanced graphics required. Phil. |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2932 |
LOAD IMAGE requires the 'picture' to be drawn each time you switch to the screen where you want to see the 'picture'. As Load Image is a non-advanced GUI control, it is not automatically switched on and off when switching PAGEs. Peter's code (from memory) allowed images to be loaded first onto 'separate' pages, and then page switching to give the appearance of quick drawing. II will have a look to see if I can find his post . . . |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2932 |
Here is the link - it was for a 44-pinner and 4.3" TFT. |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
I need a "little" help I'm decoding weather data from the serial port, and trying to display the icon relating to todays weather I've done this I've declared both ICON and ICON1 AS STRING I've also tried DIM ICON AS FLOAT and the same with icon1 and it does't make any difference If icon = "01d" Then icon1 = "01d.ppm" Error: Incompatible types in expression This is the first part of the sub where the part of the program is located icon = VAL(FieldArray$(2)) IF icon = "01d" THEN icon1 = "01d.ppm" ELSE IF icon = "01n" THEN icon1 = "01n.ppm" Anyone know what I'm doing wrong, and more importantly - how to correct the error? |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 1000 |
icon = VAL(FieldArray$(2)) 'VAL() sets icon as a number.\\ IF icon = "01d" THEN icon1 = "01d.ppm" // This is expecting icon to be a string. Try the first line as icon = FieldArray$(2) Regards Gerry Latest F4 Latest H7 FotS |
||||
WhiteWizzard Guru ![]() Joined: 05/04/2013 Location: United KingdomPosts: 2932 |
Lewis, Try keeping things as simple as possible and use a $ at the end of a variable name that contains a string. Anything in quotes (speech marks) is a string. A number is not a string and hence: icon = "01d" is incorrect and will result in: Error: Incompatible types in expression (as left side is expecting a number, and right side is a string. icon$ = "01d" is correct as both sides of the 'equation' are strings. icon = val("01d") is also correct as both sides are 'numbers' |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Thanks both Phil - If i do that then I get the error If icon$ = "01d" Then icon1$ = "01d.ppm" Error: ICON already declared IF I try icon = FieldArray$(2) then the error is icon = FieldArray$(2) |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Whoops Typo The error if I try icon = FieldArray$(2) Error: Expected a number EDIT: I sorted it by going at it a different way However now I have the same problem Error: ICON already declared |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
@Matherp A problem you "hopefully" will know the answer to Peter [code]SUB T1 IF FieldArray$(2) = "01d" THEN FieldArray$(2) = "01d.ppm" ELSE IF FieldArray$(2) = "01n" THEN FieldArray$(2) = "01n.ppm" ELSE IF FieldArray$(2) = "02d" THEN FieldArray$(2) = "02d.ppm" ELSE IF FieldArray$(2) = "02n" THEN FieldArray$(2) = "02n.ppm" ELSE IF FieldArray$(2) = "03d" THEN FieldArray$(2) = "03d.ppm" ELSE IF FieldArray$(2) = "03n" THEN FieldArray$(2) = "03n.ppm" ELSE IF FieldArray$(2) = "04d" THEN FieldArray$(2) = "04d.ppm" ELSE IF FieldArray$(2) = "04n" THEN FieldArray$(2) = "04n.ppm" ELSE IF FieldArray$(2) = "09d" THEN FieldArray$(2) = "09d.ppm" ELSE IF FieldArray$(2) = "09n" THEN FieldArray$(2) = "09n.ppm" ELSE IF FieldArray$(2) = "10d" THEN FieldArray$(2) = "10d.ppm" ELSE IF FieldArray$(2) = "10n" THEN FieldArray$(2) = "10n.ppm" ELSE IF FieldArray$(2) = "11d" THEN FieldArray$(2) = "11d.ppm" ELSE IF FieldArray$(2) = "11n" THEN FieldArray$(2) = "11n.ppm" ELSE IF FieldArray$(2) = "13d" THEN FieldArray$(2) = "13d.ppm" ELSE IF FieldArray$(2) = "13d" THEN FieldArray$(2) = "13n.ppm" ELSE IF FieldArray$(2) = "13d" THEN FieldArray$(2) = "50d.ppm" ELSE IF FieldArray$(2) = "50d" THEN FieldArray$(2) = "50n.ppm" END IF PRINT FieldArray$(2) DisplayPicture FieldArray$(2) , 392 , 185 END SUB[/code] Error = [196] SDcard fileopen,PIC$ Error: No File Any idea what this might mean Peter? The program will quite happily display .ppm pictures if I call them directly, and all the .ppm pictures are on the SD card and I just checked them all and they all open normally just not when called by this routine EDIT: I'm using your code for loading .ppm pictures from Here |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |