Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 14:36 29 Nov 2024 Privacy Policy
Jump to

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 : PicoMiteWeb V5.07.07a23+ - New functionality from an idea by Geoff

Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 9139
Posted: 07:15pm 11 Mar 2023
Copy link to clipboard 
Print this post

V5.07.07a23


PicoMiteWebV5.07.07a23.zip


This has some fun new features
First there are two new "display" drivers
VIRTUAL_C and VIRTUAL_M

These are virtual drivers that allow you to use all the graphics routines without any display attached. In both cases a 38400 byte framebuffer is created when a graphics command is invoked for the first time. VIRTUAL_C is a 320x240 16 colour display and VIRTUAL_M is a 640x480 mono display.

In addition there is a new version of SAVE IMAGE. SAVE COMPRESSED IMAGE creates a BMP file but with run length encoding of the image data. This can result in a huge reduction in file size for graphics images (as compared to pictures). To work with this LOAD IMAGE has also been enhanced to support 16-colour BMP files with run length encoded data.

What is this all about I hear you cry?

This is the email I got from Geoff

  Quote  It occurred to me that you might be able to use your FRAMEBUFFER code to create a framebuffer without a configured LCD display and also modify the SAVE IMAGE command to save this framebuffer as a BMP file.  This would allow the BASIC program to draw a graph (perhaps of historical data) and save it as an image to be embedded in the web page that the PicoW is also serving.

It would be a neat way for the PicoW to embed dynamic graphical images in a web page with little complication.  


The work to do this basically borrowed the display infrastructure from the PicoMiteVGA but used it without any linkage to an output device.

When I first tried to use it the standard bmp files were large and resulted in long update times for a web page. Searching the web showed that any of the more sophisticated image formats were too memory hungry to create on the Pico (jpg, gif png etc.) but I found that there is an option in BMP files to add compression. There is virtually no online documentation for this (just this  ) but it seems to be supported by browsers and image programs so with a lot of trial and error I got it working.




This 320x240 image is only 3812 bytes in the compressed version vs 38518 bytes uncompressed. Obviously the file size increases with the complexity of the image.

So the new commands are

OPTION LCDPANEL VIRTUAL_C
OPTION LCDPANEL VIRTUAL_M
SAVE COMPRESSED IMAGE fname$ [,xleft, ytop, width, height]


Note that for the compressed images xleft and width must both be even numbers

Example program

Drive "b:"
Dim buff%(512)
Dim myfloat!=16.123
Dim myint%=999
Dim mystring$="The PicoMite Web is GO!!!"
WEB ntp
WEB tcp interrupt poll
CLS RGB(blue)
Do
Font 6
Text MM.HRes\2,MM.VRes\2,Time$,CM,,,RGB(red),RGB(blue)
Save compressed image "B:/rle"
Pause 10000
Loop
'
Sub poll
Local p%, t%
For a%=1 To MM.Info(max connections)
LongString clear buff%()
WEB tcp read a%,buff%()
p%=LInStr(buff%(),"GET")
t%=LInStr(buff%(),"HTTP")
If LLen(buff%()) Then Print "_________________________________________________
"
s$=""
If (p%<>0) And  (t%<>0) And (t%>p%) Then
  s$=LGetStr$(buff%(),p%,t%-p%+4)
  Print "String is ",s$
EndIf
If Instr(s$,"rle") Then
  Print "sending picture"
  WEB Transmit FILE a%,"rle.bmp","image/bmp"
ElseIf Instr(s$,"favicon") Then
  Print "sending icon"
  WEB Transmit FILE a%,"favicon.ico","image/vnd.microsoft.icon"
ElseIf Instr(s$,"HTTP") Then
  Print "sending page"
  WEB transmit page a%,"test4.html"
EndIf
Next a%
End Sub


Example HTML (icon must be on a single long line)
<html>
<head>
<title>PicoMiteWeb Test</title>
<link rel="icon" type="image/x-icon" sizes="16x16" href="data:image/png;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAA
AAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAP//ADMA/wD/AAQAFf8AAAIACABZAP8AAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAAUAVQBVAAUABQUABQBQBVAFBQAFAFAFBQAA
VQBVAAUFBQAAAAAABVAAAAAAAAAAAAAAAAAAACREMzERAAAAJkRDMxEQAAAmZEQzMREAAAZmREMzERAAA
GZkRDMxEQAABmZEQzMREAAAZmREMzERAAAGZkRDMxH//wAAuzMAALrtAACa7QAArzMAAKv/AACf/wAA//
8AAAA/AAAAHwAAAA8AAIAHAADAAwAA4AEAAPAAAAD4AAAA" />
</head>
<body>
<h1>{mystring$}</h1>

This is a paragraph.



Test of a float: myfloat is {myfloat!}


Test of an integer: myint is {myint%}


Test of a string: mystring is {DateTime$(now)}


Test of a missing variable: missing is {missing}




</body>
</html>

Edited 2023-03-12 05:26 by matherp
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6814
Posted: 08:08pm 11 Mar 2023
Copy link to clipboard 
Print this post

That's rather cool....  :)
So, with the new version of LOAD IMAGE we can now grab game background images, for example, from a file? Is the unpacking reasonably quick?
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6102
Posted: 08:38pm 11 Mar 2023
Copy link to clipboard 
Print this post

Thanks for this.
I can stop working on my BMP-direct-to-disk charting code.
This will be MUCH easier.

Jim
VK7JH
MMedit   MMBasic Help
 
Pluto
Guru

Joined: 09/06/2017
Location: Finland
Posts: 359
Posted: 09:37pm 11 Mar 2023
Copy link to clipboard 
Print this post

 
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3152
Posted: 10:05pm 11 Mar 2023
Copy link to clipboard 
Print this post

Super addition. Thanks, and thanks to Geoff.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024