Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : GUI BITMAP issues
Author | Message | ||||
Intellecta Newbie Joined: 07/05/2016 Location: AustraliaPosts: 22 |
Dear members Trying to use the BITMAP command to make some custom symbols for a data logging example we are developing for schools - MM28/screen/RTC/EEPROM/18b20 etc. The bitmap option looks interesting but I have been unable to get anything to show on the screen. I have tried binary integer representation as a good way to show the bitmap with no success. Trolled through the examples and good not find a good piece of code to assist/emulate. An assistance would be appreciated. Thanks Tony Pugatschew option explicit option base 1 dim Integer IMAGEBITS(8) = (1, 1, 1, 2, 3, 4, 5, 6) ' tried &b00000001 etc ' Just show something - imagebits is not real symbol at this time do gui bitmap 50, 50, IMAGEBITS , 8, 8, 1, rgb(cyan), rgb(blue) Get errors such as indefined array loop |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5923 |
You can't use an array for the bitmap. The easiest way is to see what you are doing is to use a string. For 8 bytes a 64 bit integer is also OK once you have the data worked out. using integers: Jim VK7JH MMedit MMBasic Help |
||||
Intellecta Newbie Joined: 07/05/2016 Location: AustraliaPosts: 22 |
Dear Jim, Thanks for the feedback and the solution. Works a charm!!. Maybe this example should be added to the manual for future references. Will start to write some examples for the MM28 for our school program. As usual we are facing issues regarding visual programming versus text entry. Luckily the Australian curriculum supports text entry for years 7 and above. I sort of like the picaxe flow chart entry to support the development of programming skills. We can abstract the details for some mm commands and look at subroutines etc. Jim , thanks again. Where are you in Tasmania? We will be in Strahan for two weeks from Sunday and you are most welcome for a cuppa etc. Tony Pugatschew Ps. We developed a MM28 board with on board cp2102 controller to prevent loss of adapters in the class. On board 5V regulator, 3.3V regulator, USB A connector to prevent SMD parts being ripped off. Bring our more 5V, GND, VIN lines etc. Cannot make it idiot proof but doing aggressive design. |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5923 |
Hopefully the weather has improved a bit in Strahan by then. I am in hills behind Burnie. One degree this morning. Lucky the wind had dropped a bit. Jim VK7JH MMedit MMBasic Help |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
Jim, bringing up this thread from last Oct. here, but when you said that for the basic graphics GUI BITMAP command: does this mean that if using an integer variable (64 bit) it can at maximum provide the data for the default 8x8 bitmap, (or 16x4, 32x2 or 64x1)? If so then a bigger bitmap, say 32x32, would presumably have to be specified using a string variable with the 'normal' size (also the maximum size) of 256 bytes and this 256 bytes then defines the maximum size of bitmap that can be specified. I'm having trouble working this command out - could you show me the string that would need to be used for a 32x32 'simple' bitmap e.g. a diagonal line or something please. Also,is there a utility to produce appropriate strings from a bitmap grid that you know of? Greg |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8601 |
A 32x32 bitmap will need a string of length 128 (32x32/8) and each line will take 4 bytes For simplicity of understanding define the string as follows: l1$=chr$(&B10000000)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000) l2$=chr$(&B01000000)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000) l3$=chr$(&B00100000)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000) ...... l32$=chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000001) bitmap$=l1$+l2$+l3$+.....+l32$ gui bitmap 0,0,bitmap$,32,32 and you should get a diagonal line from 0,0 to 31,31 |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
Great, thanks Peter. It definitely does do exactly as you said and I think I understand now - thanks a lot. Converting a bitmap (of say a valve symbol or pump or some-such) to the byte string list is going to be a bit of a pain though unless there's a utility like Jim's FontTweak for it. Here's the code for anyone else who wants to try it - just remove the REM quote on the second line of the 'bitmap$=...' before you try it though. I guess that also means the maximum square grid we can use is 40x40 ??, i.e. closest multiple of 8 to the sq.rt.of 2048 - is that right? Greg l1$=chr$(&B10000000)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000) l2$=chr$(&B01000000)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000) l3$=chr$(&B00100000)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000) l4$=chr$(&B00010000)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000) l5$=chr$(&B00001000)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000) l6$=chr$(&B00000100)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000) l7$=chr$(&B00000010)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000) l8$=chr$(&B00000001)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000) l9$=chr$(&B00000000)+chr$(&B10000000)+chr$(&B00000000)+chr$(&B00000000) l10$=chr$(&B00000000)+chr$(&B01000000)+chr$(&B00000000)+chr$(&B00000000) l11$=chr$(&B00000000)+chr$(&B00100000)+chr$(&B00000000)+chr$(&B00000000) l12$=chr$(&B00000000)+chr$(&B00010000)+chr$(&B00000000)+chr$(&B00000000) l13$=chr$(&B00000000)+chr$(&B00001000)+chr$(&B00000000)+chr$(&B00000000) l14$=chr$(&B00000000)+chr$(&B00000100)+chr$(&B00000000)+chr$(&B00000000) l15$=chr$(&B00000000)+chr$(&B00000010)+chr$(&B00000000)+chr$(&B00000000) l16$=chr$(&B00000000)+chr$(&B00000001)+chr$(&B00000000)+chr$(&B00000000) l17$=chr$(&B00000000)+chr$(&B00000000)+chr$(&B10000000)+chr$(&B00000000) l18$=chr$(&B00000000)+chr$(&B00000000)+chr$(&B01000000)+chr$(&B00000000) l19$=chr$(&B00000000)+chr$(&B00000000)+chr$(&B00100000)+chr$(&B00000000) l20$=chr$(&B00000000)+chr$(&B00000000)+chr$(&B00010000)+chr$(&B00000000) l21$=chr$(&B00000000)+chr$(&B00000000)+chr$(&B00001000)+chr$(&B00000000) l22$=chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000100)+chr$(&B00000000) l23$=chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000010)+chr$(&B00000000) l24$=chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000001)+chr$(&B00000000) l25$=chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B10000000) l26$=chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B01000000) l27$=chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00100000) l28$=chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00010000) l29$=chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00001000) l30$=chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000100) l31$=chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000010) l32$=chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000000)+chr$(&B00000001) bitmap$=l1$+l2$+l3$+l4$+l5$+l6$+l7$+l8$+l9$+l10$+l11$+l12$+l13$+l14$+l15$+l16$ '+l17$+l18$+l19$+l20$+l21$+l22$+l23$+l24$+l25$+l26$+l27$+l28$+l29$+l30$+l31$+l32$ gui bitmap 0,0,bitmap$,32,32 |
||||
robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2294 |
note that those 32 strings will consume in excess of 8k of RAM if they are the default length of 255 characters; in some applications this may be an issue. a more 'economical' approach would be to use an array of strings: Dim L$(32) length 4 L$(1)=chr$(&B10000000)+... ... L$(32)=...+chr$(&B00000001) bitmap$="" for I=1 to 32 bitmap$=bitmap$+L$(I) next I or you could place the bitmap numbers into DATA statements, which could then be read and poked into the string. cheers, rob :-) |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
Yes, good point Robert - your example above is nice and straightforward. It'd be a good example for Geoff to expand his explanation on page 20 of the 'standard' Micromite Manual. Greg |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5923 |
Would something like that do? Create your image in FontTweak at the required size. In the file menu, select "save char as GUI bitmap string" Paste resulting file into your program This version of FontTweak needs more work so use carefully. I haven't updated the help file yet and there are no sanity checks. 2017-01-30_041546_FontTweak.zip Jim VK7JH MMedit MMBasic Help |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
Great stuff Jim, now I just have to learn to draw! I've been with the grandchildren all day so just got on to this. Didn't know you were such an old romantic - I wondered about a cupid for a reply but decided I couldn't make it cute enough. How much trouble would it be to make the bitmap size variable - and rectangles as well as squares? Here's one for you anyway. Greg EDIT: BTW how do you produce your nice coloured MMEdit output for the forum. I remember you posting about it earlier but I'm not sure what to search for: I'm sure it isn't 'magic'! ' JimsSmiley.bas myBm$ = "" myBm$ = myBm$+CHR$(128)+CHR$(0)+CHR$(0)+CHR$(0)+CHR$(64)+CHR$(0)+CHR$(112)+CHR$(0) myBm$ = myBm$+CHR$(32)+CHR$(0)+CHR$(216)+CHR$(0)+CHR$(16)+CHR$(1)+CHR$(136)+CHR$(0) myBm$ = myBm$+CHR$(8)+CHR$(1)+CHR$(0)+CHR$(0)+CHR$(4)+CHR$(1)+CHR$(0)+CHR$(0)+CHR$(2) myBm$ = myBm$+CHR$(1)+CHR$(0)+CHR$(0)+CHR$(1)+CHR$(7)+CHR$(128)+CHR$(0)+CHR$(0) myBm$ = myBm$+CHR$(156)+CHR$(112)+CHR$(0)+CHR$(0)+CHR$(112)+CHR$(28)+CHR$(0)+CHR$(0) myBm$ = myBm$+CHR$(96)+CHR$(6)+CHR$(0)+CHR$(0)+CHR$(144)+CHR$(2)+CHR$(0)+CHR$(1) myBm$ = myBm$+CHR$(136)+CHR$(3)+CHR$(0)+CHR$(1)+CHR$(4)+CHR$(1)+CHR$(128)+CHR$(3) myBm$ = myBm$+CHR$(50)+CHR$(49)+CHR$(128)+CHR$(2)+CHR$(49)+CHR$(48)+CHR$(128)+CHR$(2) myBm$ = myBm$+CHR$(0)+CHR$(128)+CHR$(128)+CHR$(3)+CHR$(1)+CHR$(65)+CHR$(128)+CHR$(3) myBm$ = myBm$+CHR$(1)+CHR$(33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(0)+CHR$(0)+CHR$(0)+CHR$(0)+CHR$(0)+CHR$(0)+CHR$(0)+CHR$(0) myBm$ = myBm$+CHR$(0)+CHR$(0)+CHR$(0)+CHR$(0)+CHR$(0)+CHR$(0) ' End Define bitmap GUI BITMAP 0,0,myBm$,32,32 |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5923 |
You can set the font size when you start a new font. I will update FontTweak to add the GUI BITMAP code line but I will wait until the width and height order is fixed. To get the coloured code, try "format for TBS" in the file menu. First, select the code you want to post or if no code is selected, the full program is copied into the clipboard ready to paste into your post. I had the heart available from when I used it in a heart rate monitor. Jim VK7JH MMedit MMBasic Help |
||||
paceman Guru Joined: 07/10/2011 Location: AustraliaPosts: 1329 |
Ah, should have realized that - I wasn't really thinking of it as a font. Great - it would probably be worth adding FontTweak to the File menu in MMEdit as you've done with 'TFT Colour'. I think it would be worth adding the size of the bitmap to the filename comment line too. Otherwise it's not easy to know what size to specify in the GUI BITMAP command if the bitmap(s) were done previously. The one below is 16x16. BTW, I didn't find a description of how to use the 'Format for TBS' in MMEdit's Help file; am I a bit blind or was it missed? I can do it now though. Greg |
||||
Print this page |