Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:51 02 Aug 2025 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 : MM2: Searching for the perfect gauge

     Page 1 of 3    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 06:55am 31 May 2015
Copy link to clipboard 
Print this post

I'm playing with the development of some instruments for measuring things like Exhaust gas temperature (EGT), Cylinder head temperature, RPM etc. The display I'm using is the ILI9163 which is small (the unit must fit in a 2" circle) and bright. The code should run on an ILI9341 but I haven't tried it. However, as always, my coding is not complemented by my complete lack of artistic ability.

The display must be easily visible and the needle position must refresh without too much flicker. This is the best I have been able to come up with:





Comments, criticisms and alternative code greatly appreciated.


Option default none
Option explicit
CPU 48
Const stepsize=3
const displaystring="EGT"
dim integer lastx1, lastx2, lastx3, lasty1, lasty2, lasty3 ' Global variables to store last pointer position
Const greenstart=-150, yellowstart=0, redstart=75, blackstart = 150 ' position of display bands in degrees - must be in ascending order
Dim integer i, radius, firsttime=1, needlelength
If MM.HRes<=MM.VRes Then ' set the radius of the display less the "bezel"
radius=MM.HRes/2-4
Else
radius=MM.VRes/2-4
EndIf
needlelength= radius\5*4-1
Circle MM.HRes\2,MM.VRes\2,radius+3,0,,RGB(210,210,210),RGB(210,210,210) 'background to creat the bezel
segment(MM.HRes\2,MM.VRes\2,radius,greenstart,yellowstart, RGB(green))
segment(MM.HRes\2,MM.VRes\2,radius,yellowstart,redstart, RGB(yellow))
segment(MM.HRes\2,MM.VRes\2,radius,redstart,blackstart, RGB(red))
segment(MM.HRes\2,MM.VRes\2,radius,blackstart,greenstart+360, 0)
Circle MM.HRes\2,MM.VRes\2,needlelength+1,0,,0,0
text mm.hres\2-len(displaystring)*4,mm.hres-20,displaystring ' string centred in black segment
do ' run the pointer backwards and forwards
For i=greenstart To blackstart-1
needle(MM.HRes/2,MM.VRes/2,needlelength,i,RGB(white))
pause 10
Next i
For i=blackstart-1 To greenstart Step -1
needle(MM.HRes/2,MM.VRes/2,needlelength,i,RGB(white))
pause 10
Next i
loop
End
'
'
' Routine to draw a pointer
' Parameters are:
' x-coordinate of centre of gauge
' y-coordinate of centre of gauge
' pointer length
' radial of pointer to be drawn (0-360 degrees)
' colour to draw pointer
'
Sub needle(x As integer, y As integer, size As integer, angle As integer, col As integer)
Local integer x1,y1,x2,y2,x3,y3,x4,y4,j
x1=Sin(Rad(angle-90))*size/10 + x
y1=-Cos(Rad(angle-90))*size/10 + y
x2=Sin(Rad(angle))*size + x
y2=-Cos(Rad(angle))*size + y
x3=Sin(Rad(angle+90))*size/10 + x
y3=-Cos(Rad(angle+90))*size/10 + y
if not firsttime then
j=triangle(lastx1,lasty1,lastx2,lasty2,lastx3,lasty3,0,0)
else
firsttime=0
endif
j=triangle(x1,y1,x2,y2,x3,y3,col,col)
Circle x,y,size\10,0,,col,col)
Circle x,y,size\15,0,,0,0
Circle x,y,size\20,0,,RGB(240,240,240),RGB(240,240,240)
lastx1=x1
lastx2=x2
lastx3=x3
lasty1=y1
lasty2=y2
lasty3=y3
End Sub
'
'
' Routine to draw a segment of a circle
' Parameters are:
' x-coordinate of centre of circle
' y-coordinate of centre of circle
' radius of circle
' start radial of segment to be drawn (0-360 degrees)
' end radial of segment to be drawn (0-360 degrees)
' colour to draw segment
'
' NB if start radial and end radial are the same a line will be drawn
'
Sub segment(x As integer, y As integer, size As integer, startradial As integer, endradial As integer, colour As integer)
Local integer i,j,x1,x2,y1,y2,sr,er
If startradial=endradial Then
x2=Sin(Rad(startradial))*size + x
y2=-Cos(Rad(startradial))*size + y
Line x,y,x2,y2,,colour
Else
If startradial<endradial Then
sr=startradial
er=endradial
Else
er=startradial
sr=endradial
EndIf
For i=sr+stepsize To er Step stepsize
x2=Sin(Rad(i))*size + x
y2=-Cos(Rad(i))*size + y
x1=Sin(Rad(i-stepsize))*size + x
y1=-Cos(Rad(i-stepsize))*size + y
j=triangle(x1,y1,x2,y2,x,y,colour,colour)
Next i
EndIf
End Sub
'
' Routine to draw a triangle
'
' Parameters are:
' x-coordinate of first point
' y-coordinate of first point
' x-coordinate of second point
' y-coordinate of second point
' x-coordinate of third point
' y-coordinate of third point
' colour to draw triangle outline
' colour to fill triangle use -1 for outline only
'
CFunction triangle
00000000
27bdffa0 afb40048 8fb4007c 8ce90000 8e820000 afa50064 8fa30064 afa60068
afa7006c 8fa70070 afa40060 8c850000 8c660000 8fa40068 8fa30074 8ce80000
2407ffff afbe0058 afb70054 8c9e0000 8c770000 afbf005c afb60050 afb5004c
afb30044 afb20040 afb1003c afb00038 00401821 104700f4 8e840004 0126202a
afa60020 afa90018 10800005 00a09821 03c09821 afa90020 afa60018 00a0f021
8fa50018 02e5202a 10800006 afa80024 03c02021 afb70018 0100f021 00a0b821
afa40024 8fa60020 8fa70018 00e6202a 148000ac 02602021 8fa40020 509700b0
03d3182a 8fa70018 10f70002 8fa60018 24e6ffff 8fa90020 00c9202a 148000e1
8fa70024 8fa20018 03d32823 00f32023 0049b023 02e9a823 afbe0028 afb7002c
afb4001c 01208021 00009021 00008821 3c029d00 00a0b821 0080f021 10000003
00c0a021 8fa4001c 8c830000 0236001a 02c001f4 02002821 02003821 02378821
26100001 00002012 0255001a 02a001f4 00932021 00804021 00003012 00d33021
00c4482a 11200003 025e9021 00c02021 01003021 afa30010 8c430048 0060f809
afa20030 0290182a 1060ffe6 8fa20030 8fb4001c 8fbe0028 8e830000 8fb7002c
00601021 02f0202a 148000ab 8fa70018 8fa50024 8fa90020 00b3b023 00be3023
02079023 02098823 02e92023 72368802 afb40018 afa6001c 02c0a021 72469002
0260b021 02e7a823 3c029d00 10000003 00809821 8fa40018 8c830000 0255001a
02a001f4 8fa6001c 02002821 02469021 02003821 26100001 00002012 0233001a
026001f4 009e2021 00804021 00003012 00d63021 00c4482a 11200003 02348821
00c02021 01003021 afa30010 8c430048 0060f809 afa20030 02f0182a 1060ffe5
8fa20030 8fb40018 8e830000 8e840004 8fa50078 8ca20000 1043005d 8ca50004
8fa3006c 8fa60060 8fa70064 8fa90068 24110001 8cc40000 8ce50000 8d260000
8c670000 3c109d00 afb10010 afa20014 8e020050 0040f809 00000000 8fa40078
8fa50068 8c820000 8fa6006c 8fa70070 8fa90074 8ca40000 8cc50000 8ce60000
8d270000 afb10010 afa20014 8e020050 0040f809 00000000 8fa30078 8fa50070
8c620000 8fa60074 8fa70060 8fa90064 8ca40000 8cc50000 8ce60000 8d270000
afb10010 afa20014 8e020050 0040f809 00000000 8fbf005c 8fbe0058 8fb70054
8fb60050 8fb5004c 8fb40048 8fb30044 8fb20040 8fb1003c 8fb00038 03e00008
27bd0060 afa70020 03c09821 0080f021 8fa40020 1497ff53 afa60018 03d3182a
1460002d 8fa50024 027e182a 14600030 03c03821 02603821 02602021 8fa50024
00a4182a 54600003 8fa40024 00e5182a 00a3380b 8fa60020 afa20010 3c029d00
00e63821 8c420048 00c02821 00e43823 0040f809 00803021 8fa50078 8e830000
8ca20000 8e840004 1443ffa5 8ca50004 54a4ffa4 8fa3006c 8fbf005c 8fbe0058
8fb70054 8fb60050 8fb5004c 8fb40048 8fb30044 8fb20040 8fb1003c 8fb00038
03e00008 27bd0060 5482ff0d 0126202a 1000ff90 8fa50078 03c02021 00a4182a
1060ffda 02603821 1000ffda 8fa40024 1000ffd2 02602021 00401821 1000ff84
8e840004 1000ff4f 8fb00020
End CFunction
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 07:20am 31 May 2015
Copy link to clipboard 
Print this post

Hi Matherp, this looks real nice. What kind of response (speed wise) are you getting with the needle? Is there any way you could video clip it? (Not that your aren't busy enough already)

EDIT...

Would you put a changing numerical value in the screen also?Edited by viscomjim 2015-06-01
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 07:22am 31 May 2015
Copy link to clipboard 
Print this post

Time to reposition the pointer is between 7 and 8 msecs
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 07:34am 31 May 2015
Copy link to clipboard 
Print this post

Hi Matherp, I tried your code but am running a ILI9341 display 2.4". This is what I got...

CPU exception #6 (bus error on ifetch) at address 0x383420
Processor restarted


 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 07:54am 31 May 2015
Copy link to clipboard 
Print this post

Are you running 4.7beta 8?

Video here Edited by matherp 2015-06-01
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 07:56am 31 May 2015
Copy link to clipboard 
Print this post

OOOOOOOOOPPPPPPPPSSSSSSS!!!!! My Bad. Running beta 3. Will update and tried again...

Loaded beta8 all is well. Here is a pic on the 2.4" display, the picture does not do it any justice. It looks really clean. You can't see the lines that are showing up in the picture. It just looks great!





Edited by viscomjim 2015-06-01
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 03:39pm 31 May 2015
Copy link to clipboard 
Print this post

Works well and looks good on my ILI9341 2.8" Peter - but there's a strange effect on the needle. It moves smoothly but bulk sections of the colour flicker between white and grey as it moves around. Actually it's not so much a flicker as sort of random, but seems to be the same each time it's run. At one point it travels about 30 deg. with half the needle white and half grey - that's across the needle. At other times it's more longitudinal or at angle to the needle axis and random.

Maybe a raster interference or timing issue?

Greg

Edit: Just tried it with the 2.4" screen and have the same effect.Edited by paceman 2015-06-02
 
Zonker

Guru

Joined: 18/08/2012
Location: United States
Posts: 767
Posted: 04:16pm 31 May 2015
Copy link to clipboard 
Print this post

Nice Peter..!!

Now your talkin..! Aircraft Gauges.. Got my attention..

Maybe add the "white" section on the bottom of the gauge scale.. I have seen the same on some of the stuff around the airport... That way, there would be 3 scale set points the user could setup depending on the type of engine they are running with... We could come up with a setup screen and store the user settings in flash...

I have a MAX31855 Thermocouple "front end" board that hooks up to the SPI port...

Humm... I will try to have a go at this during the week.. Looks sweet Pete..!!

There should be some looking into creating an altimeter and airspeed also..

(mouth watering)..

EDIT: I just got a chance to see your code running on the 2.4" Nice..!
You took your triangle program and made a gauge face out of it... (sweet)
Tricky thinking Peter..!Edited by Zonker 2015-06-02
 
hitsware
Guru

Joined: 23/11/2012
Location: United States
Posts: 535
Posted: 04:29pm 31 May 2015
Copy link to clipboard 
Print this post

Artsy as H*ll (and not raining on any parades),
but wouldn't a simple numerical readout be more effective ?
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2950
Posted: 06:06pm 31 May 2015
Copy link to clipboard 
Print this post

G'Day Peter,


It runs on the 2.8 ILI9341 but as Greg has found there is an annoying grey artifcat when it draws the white needle..

Also I dont get the EGT or the value under it.. I get the same as the picture Jim added..

As to your artistic talents, They are better than mine for sure..

I would suggest that if a guage goes into the RED that a flashing RED background would be good to draw attention to the fact.

Regards,

Mick



Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2950
Posted: 06:40pm 31 May 2015
Copy link to clipboard 
Print this post

@Geoff

There appears to be a bug (or is it a feature) in 4.7b8 with the OPTION LCDPANEL command..

If the option has been set already trying it again or trying to change the orientation (landscape/portrait etc) returns an INVALID PIN error..

It requires an issue of OPTION LCDPANEL DISABLE to change it to a different orientation..

It may be by design..

@Peter, I noticed in your vid clip that the orientation was portrait..

I set to portrait and the grey artifacts were no where near as bad but it was still there and in reverse portrait it was pretty bad and maybe a bit worse than Landscape..

Also in portrait mode I get the EGT but no numbers...

Mick





Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 08:01pm 31 May 2015
Copy link to clipboard 
Print this post

  hitsware said  
but wouldn't a simple numerical readout be more effective ?

Analogue gauges are quicker to read at a glance when you don't need precise values.
If you have a row of meters, a quick look can tell you that all is well.

Analogue gauges are easier to read if the level is constantly changing (provided the needle moves quick enough)- VU meters etc.

Jim
VK7JH
MMedit
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 10:49pm 31 May 2015
Copy link to clipboard 
Print this post

There appears to be a bug (or is it a feature) in 4.7b8 with the OPTION LCDPANEL command.


This is how Geoff has designed it, I have asked for a rotate command to be included but this is still on the to-do maybe list.

  Quote  Also in portrait mode I get the EGT but no numbers...

The version posted above was before viscomjim asked for numbers which I then added and posted the video. New code below.

  Quote  I would suggest that if a guage goes into the RED that a flashing RED background would be good to draw attention to the fact.

Good idea I'll have a look at that

  Quote  Maybe add the "white" section on the bottom of the gauge scale.

This is easy for you to do or for any colour changes just modify the constants that define the segment start points and add another segment call to draw it.

  Quote  Actually it's not so much a flicker as sort of random, but seems to be the same each time it's run. At one point it travels about 30 deg. with half the needle white and half grey

This seems to be an artifact of the way the pixel updates take place relative to the raster refresh on the ILI9341. There is almost no effect on the ILI9163 and the ST7735 is about halfway between. I'm not sure if there is a way round this but remember at the moment the update rate is around 25 position changes/second. For a real EGT this would be 1/sec so the effect wouldn't really be visible.

Replacement main program code to display the text and numbers properly and scale the font depending on the screen size:


Option default none
Option explicit
CPU 48
Const stepsize=3
const displaystring="EGT"
dim integer lastx1, lastx2, lastx3, lasty1, lasty2, lasty3 ' Global variables to store last pointer position
Const greenstart=-150, yellowstart=0, redstart=75, blackstart = 150 ' position of display bands in degrees - must be in ascending order
Dim integer i, radius, firsttime=1, needlelength, fontmult
dim s$
If MM.HRes<=MM.VRes Then ' set the radius of the display less the "bezel"
radius=MM.HRes/2-4
Else
radius=MM.VRes/2-4
EndIf
if mm.hres>160 then
font 1,2
fontmult=2
else
font 1,1
fontmult=1
endif
needlelength= radius\5*4-1
Circle MM.HRes\2,MM.VRes\2,radius+3,0,,RGB(210,210,210),RGB(210,210,210) 'background to creat the bezel
segment(MM.HRes\2,MM.VRes\2,radius,greenstart,yellowstart, RGB(green))
segment(MM.HRes\2,MM.VRes\2,radius,yellowstart,redstart, RGB(yellow))
segment(MM.HRes\2,MM.VRes\2,radius,redstart,blackstart, RGB(red))
segment(MM.HRes\2,MM.VRes\2,radius,blackstart,greenstart+360, 0)
Circle MM.HRes\2,MM.VRes\2,needlelength+1,0,,0,0
text mm.hres\2-len(displaystring)*4*fontmult,mm.vres-fontmult*33,displaystring ' string centred in black segment
do ' run the pointer backwards and forwards
For i=greenstart To blackstart-1
s$=str$(i,4)
needle(MM.HRes/2,MM.VRes/2,needlelength,i,RGB(white))
text mm.hres\2-len(s$)*4*fontmult-4*fontmult,mm.vres-fontmult*19,s$ ' string centred in black segment
pause 10
Next i
For i=blackstart-1 To greenstart Step -1
s$=str$(i,4)
needle(MM.HRes/2,MM.VRes/2,needlelength,i,RGB(white))
text mm.hres\2-len(s$)*4*fontmult-4*fontmult,mm.vres-fontmult*19,s$ ' string centred in black segment
pause 10
Next i
loop
End
'
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 01:07am 01 Jun 2015
Copy link to clipboard 
Print this post

Interesting - this version is much better in relation to the 'flicker' artifact i.e. on the 2.8" ILI9341 screen. But as you say Peter, with a low refresh rate it shouldn't matter.

Greg
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 03:27am 01 Jun 2015
Copy link to clipboard 
Print this post

Here is a new version better implemented that supports multiple gauges on the same display




All the colour segments, locations and sizes are now parameterised so it is much more flexible.
I've also re-written the triangle drawing routine to output multiple triangles in a single call to the Cfunction. This allows the blanking pointer and the re-draw to be done together as fast as possible. This has reduced the appearance of the artifact but it is still there. The ili9163 is much the best display for a single gauge but the bigger displays are more flexible as above.


Option default none
Option explicit
CPU 48
Const stepsize=1
const maxgauges=8
dim integer x(maxgauges), y(maxgauges), radius(maxgauges), fontsize(maxgauges)
dim integer lastx1(maxgauges), lastx2(maxgauges), lastx3(maxgauges), lasty1(maxgauges), lasty2(maxgauges), lasty3(maxgauges)
dim integer whitesec(maxgauges),greensec(maxgauges),yellowsec(maxgauges),redsec(maxgauges),blacksec(maxgauges)
dim integer i,j
dim s$
initgauge(0,53,60,49,1,-150,-100,0,75,150,"EGT")
initgauge(1,159,60,49,1,-150,-120,0,120,150,"CHT")
initgauge(2,265,60,49,1,-150,-50,0,50,150,"OIL")
initgauge(3,53,180,49,1,-120,-120,0,75,120,"AMP")
initgauge(4,159,180,49,1,-90,-90,0,75,90,"OAT")
initgauge(5,265,180,49,1,-150,-150,0,75,150,"VOLT")
do ' run the pointer backwards and forwards
for j=0 to 5
i=rnd(22)* (blacksec(j)-whitesec(j)) + whitesec(j)
s$=str$(i,4)
needle(j,i,rgb(white),s$)
next j
pause 500
loop
End
'
' Routine to initialise a gauge
' Parameters are:
' gaugeindex
' x-coordinate of centre of gauge
' y-coordinate of centre of gauge
' radius of gauge
' font size
' start radial of white segment (-180 to 180)
' start radial of green segment (-180 to 180, must be greater or equal to start of previous segment)
' start radial of yellow segment (-180 to 180, must be greater or equal to start of previous segment)
' start radial of red segment (-180 to 180, must be greater or equal to start of previous segment)
' start radial of black segment (-180 to 180, must be greater or equal to start of previous segment)
' string to display as gauge title
'
sub initgauge(gaugeindex% , xpos%, ypos%, gsize%, fontmult%, whitestart%, greenstart%, yellowstart%, redstart%, blackstart%, displaystring$)
Circle xpos%,ypos%,gsize%+3,0,,RGB(210,210,210),RGB(210,210,210) 'background to creat the bezel
segment(xpos%,ypos%,gsize%,whitestart%,greenstart%, RGB(white))
segment(xpos%,ypos%,gsize%,greenstart%,greenstart%, 0)
segment(xpos%,ypos%,gsize%,greenstart%,yellowstart%, RGB(green))
segment(xpos%,ypos%,gsize%,yellowstart%,redstart%, RGB(yellow))
segment(xpos%,ypos%,gsize%,redstart%,blackstart%, RGB(red))
segment(xpos%,ypos%,gsize%,blackstart%,whitestart%+360, 0)
segment(xpos%,ypos%,gsize%,greenstart%,greenstart%, 0)
segment(xpos%,ypos%,gsize%,yellowstart%,yellowstart%, 0)
segment(xpos%,ypos%,gsize%,redstart%,redstart%, 0)
Circle xpos%,ypos%, gsize%\5*4,0,,0,0
text xpos%-len(displaystring$)*4*fontmult%,ypos%+gsize%-fontmult%*28,displaystring$ ' string centred in black segment
x(gaugeindex%)=xpos%
y(gaugeindex%)=ypos%
radius(gaugeindex%)=gsize%
fontsize(gaugeindex%)=fontmult%
lastx1(gaugeindex%)=xpos%
lastx2(gaugeindex%)=xpos%+2
lastx3(gaugeindex%)=xpos%+2
lasty1(gaugeindex%)=ypos%
lasty2(gaugeindex%)=ypos%+2
lasty3(gaugeindex%)=ypos%
whitesec(gaugeindex%)=whitestart%
greensec(gaugeindex%)=greenstart%
yellowsec(gaugeindex%)=yellowstart%
redsec(gaugeindex%)=redstart%
blacksec(gaugeindex%)=blackstart%
end sub
'
' Routine to draw a pointer
' Parameters are:
' gaugeindex
' radial of pointer to be drawn (0-360 degrees)
' colour to draw pointer
'
Sub needle(gaugeindex as integer, angle As integer, col As integer, value$ as string)
Local integer x1,y1,x2,y2,x3,y3,x4,y4,j, xx1(1),yy1(1),xx2(1),yy2(1),xx3(1),yy3(1), tcol(1), size
size= radius(gaugeindex)\5*4-1
x1=Sin(Rad(angle-90))*size/10 + x(gaugeindex)
y1=-Cos(Rad(angle-90))*size/10 + y(gaugeindex)
x2=Sin(Rad(angle))*size + x(gaugeindex)
y2=-Cos(Rad(angle))*size + y(gaugeindex)
x3=Sin(Rad(angle+90))*size/10 + x(gaugeindex)
y3=-Cos(Rad(angle+90))*size/10 + y(gaugeindex)
xx1(0)=lastx1(gaugeindex)
yy1(0)=lasty1(gaugeindex)
xx2(0)=lastx2(gaugeindex)
yy2(0)=lasty2(gaugeindex)
xx3(0)=lastx3(gaugeindex)
yy3(0)=lasty3(gaugeindex)
xx1(1)=x1
yy1(1)=y1
xx2(1)=x2
yy2(1)=y2
xx3(1)=x3
yy3(1)=y3
tcol(0)=0
tcol(1)=col
j=triangles(2,xx1(),yy1(),xx2(),yy2(),xx3(),yy3(),tcol())
Circle x(gaugeindex),y(gaugeindex),size\10,0,,col,col)
Circle x(gaugeindex),y(gaugeindex),size\15,0,,0,0
Circle x(gaugeindex),y(gaugeindex),size\20,0,,RGB(240,240,240),RGB(240,240,240)
lastx1(gaugeindex)=x1
lastx2(gaugeindex)=x2
lastx3(gaugeindex)=x3
lasty1(gaugeindex)=y1
lasty2(gaugeindex)=y2
lasty3(gaugeindex)=y3
text x(gaugeindex)-len(value$)*4*fontsize(gaugeindex)-3*fontsize(gaugeindex),y(gaugeindex)+radius(gaugeindex)-fontsize(gaugei ndex)*16,value$ ' string centred in black segment

End Sub
'
'
' Routine to draw a segment of a circle
' Parameters are:
' x-coordinate of centre of circle
' y-coordinate of centre of circle
' radius of circle
' start radial of segment to be drawn (0-360 degrees)
' end radial of segment to be drawn (0-360 degrees)
' colour to draw segment
'
' NB if start radial and end radial are the same a line will be drawn
'
Sub segment(x As integer, y As integer, size As integer, startradial As integer, endradial As integer, col As integer)
Local integer i,j,x1,x2,y1,y2,sr,er,xx0(1),yy0(1),xx1(1),yy1(1),xx2(1),yy2(1),tcol(1)
If startradial=endradial Then
x2=Sin(Rad(startradial))*size + x
y2=-Cos(Rad(startradial))*size + y
Line x,y,x2,y2,,col
Else
If startradial<endradial Then
sr=startradial
er=endradial
Else
er=startradial
sr=endradial
EndIf
For i=sr+stepsize To er Step stepsize
x2=Sin(Rad(i))*size + x
y2=-Cos(Rad(i))*size + y
x1=Sin(Rad(i-stepsize))*size + x
y1=-Cos(Rad(i-stepsize))*size + y
xx0(0)=x
yy0(0)=y
xx1(0)=x1
yy1(0)=y1
xx2(0)=x2
yy2(0)=y2
tcol(0)=col
j=triangles(1,xx0(),yy0(),xx1(),yy1(),xx2(),yy2(),tcol())
Next i
EndIf
End Sub
'
' Routine to draw multiple triangles,
' can be used to draw an existing triangle in the background colour and then re-write it somewhere else
'
' Parameters are:
' number of triangles to draw
' array x-coordinates of first points
' array y-coordinates of first points
' array x-coordinates of second points
' array y-coordinates of second points
' array x-coordinates of third points
' array y-coordinates of third points
' array colours of triangles
'
CFunction triangles
00000000
8c820004 27bdffa0 afbf005c afbe0058 afb70054 afb60050 afb5004c afb40048
afb30044 afb20040 afb1003c afb00038 afa40060 afa50064 afa60068 184000e7
afa7006c afa00030 3c179d00 8fa30030 8fa50068 8fa80070 000310c0 00a22021
01021821 8c840000 8c630000 8fa90064 afa40018 01223821 afa3001c 8fa40074
8fa3006c 8fa80078 8fa9007c 00623021 00822821 01022021 01221021 8fa80018
8fa9001c 8cc60000 8ca50000 0128182a 8cf30000 8c9e0000 afa60028 afa5002c
10600006 8c540000 02601021 afa90018 00c09821 afa8001c afa20028 8fa5001c
03c5102a 10400008 8fa90018 8fa20028 8fa8002c afbe001c afa80028 00a0f021
afa2002c 8fa90018 8fa3001c 0069102a 10400008 8fa50018 8fa4001c 02601021
afa40018 8fb30028 afa9001c afa20028 8fa50018 10be007f 8fa3001c 107e009e
8fa40018 2463ffff 0064102a 1440002d 8fb00018 8fa80028 8fa9002c 8fa5001c
01134023 01334823 03c4a823 afbe0034 00a4b023 0280f021 afa80020 afa90024
00808021 00009021 00008821 0060a021 0236001a 02c001f4 8fa30024 8fa20020
02002821 02003821 02228821 26100001 00002012 0255001a 02a001f4 00932021
02439021 00003012 00d33021 00c4182a 10600003 00801021 00c02021 00403021
afbe0010 8ee20048 0040f809 00000000 0290102a 1040ffe6 00000000 03c0a021
8fbe0034 03d0102a 1440002f 8fa8001c 8fa90018 8fa4002c 8fa50028 0093a823
0085b023 02089023 02098823 03c91823 03c81023 72569002 72358802 afb40018
afb5001c afb60020 0260a821 00a0b021 00609821 0040a021 0254001a 028001f4
8fa3001c 8fa20020 02002821 02003821 02429021 26100001 00002012 0233001a
026001f4 00962021 02238821 00003012 00d53021 00c4182a 10600003 00801021
00c02021 00403021 8fa80018 afa80010 8ee20048 0040f809 00000000 03d0102a
1040ffe5 00000000 8fa90030 8fa20060 25290001 8c430004 000917c3 0043202a
1480ff5a afa90030 14620007 8fbf005c 8fa30060 8c620000 0122102b 5440ff54
8fa30030 8fbf005c 8fbe0058 8fb70054 8fb60050 8fb5004c 8fb40048 8fb30044
8fb20040 8fb1003c 8fb00038 03e00008 27bd0060 8fa80028 0113102a 14400023
02603821 0268102a 14400022 8fa70028 02603821 02602021 8fa9002c 0124102a
54400003 8fa4002c 00e9102a 0122380b 8fa20018 afb40010 00e23821 8fa50018
8ee20048 00803021 0040f809 00e43823 8fa90030 8fa20060 25290001 8c430004
000917c3 0043202a 1480ff28 afa90030 1000ffcd 00000000 0064102a 1040ff66
8fa80028 1000ff8f 8fb00018 1000ffe2 8fa40028 1000ffe0 02602021 1440ffca
8fbf005c 8c820000 5440ff17 afa00030 1000ffc6 8fbe0058
End CFunction 'MIPS32 M4K



 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 03:34am 01 Jun 2015
Copy link to clipboard 
Print this post

Matherp, I am very impressed!!!! This is GREAT!!!!! Thanks for all your hard work. Your efforts are making the uMite quite the controller for so many things, my head is spinning!!!! That goes for Geoff also of course!Edited by viscomjim 2015-06-02
 
Zonker

Guru

Joined: 18/08/2012
Location: United States
Posts: 767
Posted: 12:16pm 01 Jun 2015
Copy link to clipboard 
Print this post

OMG..! Awesome Peter

I just got home from work, and looking at the changes... I see white bars... Nice

Time for a little fun...!

EDIT: Wow... A lot of function packed into a tiny box of code..!!
Ok... I think I need to look into getting gauge setup settings in and out of flash, then create some kind of setup screen... (sweet)...
EDIT: Head Scratching going on... (thinking about scales)...Edited by Zonker 2015-06-03
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 02:41pm 01 Jun 2015
Copy link to clipboard 
Print this post

Just had a chance to try this...

HELL YEAH!!!!!!!!

uMite just stepped up!!!!

Can't say thanks enough! I can't even image where this will go....
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 02:58pm 01 Jun 2015
Copy link to clipboard 
Print this post


Wow, that's looking pretty amazing Peter - you, Geoff and Peter Carnegie should take a bow - and all on a $10 display with a $5 MX170 running the brilliant Micromite II MMBasic with CFunctions!

Greg

BTW, I can't see those artifacts at all with this version on the 2.8" using ILI9341 controller.
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2950
Posted: 07:03pm 01 Jun 2015
Copy link to clipboard 
Print this post

Brilliant Stuff,



Wow!!,

I have to go change my underwear, this is very exciting stuff.

I knew as soon as I saw Peter coming out with code for these displays that this was something special.. well YES!! It is very special. I have a display mounted in the front of my PC in the space where 2 x 3.5" floppy drives would go permanently running this demo..

Now to find a use for it on my PC desk..

I also confirm no grey artifacts seen but I do see the V and the T in Volt get over written if the value is too low or too high. But then this is a demo of course..

Regards,

Mick

Edited by bigmik 2015-06-03
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
     Page 1 of 3    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025