Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 14:07 27 Apr 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 : I’m an idiot

     Page 2 of 2    
Author Message
TrevorH
Senior Member

Joined: 06/04/2018
Location: United Kingdom
Posts: 142
Posted: 09:10pm 24 Jan 2020
Copy link to clipboard 
Print this post

  Quote  and references to autorefresh an refresh which I take to be only PI commands.


They are definitely in the Armite H7 manual.
 
TrevorH
Senior Member

Joined: 06/04/2018
Location: United Kingdom
Posts: 142
Posted: 02:40pm 25 Jan 2020
Copy link to clipboard 
Print this post

Does anyone know how to track down "cpu exception error #7" when using cfunction "triangles".

Can't get to the bottom of this, I am using the 100pin version on an E100.

Anyone???

Trevor
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8579
Posted: 05:01pm 25 Jan 2020
Copy link to clipboard 
Print this post

If you post simple code showing the problem perhaps we can help. One possibility is you are passing floating point variables rather than integers
 
TrevorH
Senior Member

Joined: 06/04/2018
Location: United Kingdom
Posts: 142
Posted: 06:42pm 25 Jan 2020
Copy link to clipboard 
Print this post

Hi,  this is what I have been working on (had it working once).

The clock is to be in top left corner.
you need to comment out options not required for your setup

Option explicit
option lcdpanel ssd1963_5, Rlandscape, 48
option touch 1, 40
option rtc 67,66
gui calibrate 1, 3959, 231, -2143, 1382
option save


const Y_top = 0 'Y coordinate of top of the image file on the screen
const X_left = 0 'X coordinate of left of the image file on the screen
const Y_point = 240 'Y coordinate of the centre of the pointer relative to the image top
const X_point = 240 'X coordinate of the centre of the pointer relative to the image left
const buffersize = 8000 'used to store the image data behind the pointer
dim integer buff(buffersize)
dim INTEGER pos1(3)=(0,270,140,30)
dim INTEGER pos2(3)=(0,411,150,30)
dim integer i,num=0,secs1
Dim integer nt=4 'Number of triangles being updated
Dim integer xx0(nt*2-1),yy0(nt*2-1),xx1(nt*2-1),yy1(nt*2-1),xx2(nt*2-1),yy2(nt*2-1),tcol(nt*2-1),secs,mins,hours,first=1
Settick 1000 ,L1,1 'establish seconds "Tick Timer"
Settick 1000 ,L2,2 'establish seconds "Tick Timer"

CLS rgb(white) 'Clear the screen
'load image "clock4.bmp",X_left,Y_top
Font 1, 2 ' Set the default font

'**********************Start of Main Program**********************************
Do
secs=Val(Right$(Time$,2))
mins=Val(Mid$(Time$,4,2))
hours=Val(Left$(Time$,2))
hands(secs,mins,hours,(82),100, 100) ' SIZE of hands, position from left, position from top
Do
Loop While Val(Right$(Time$,2))=secs 'Loop Every Second
Loop

End

'********************End of Main program*********************************************************

'L1 - 1second Tick interrupt
Sub L1
secs=secs+1 'update seconds timer
if secs => 86400 then '24 hrs reached
secs = 0 'reset counter
endif
End Sub

Sub L2
secs1 = secs1 + 1 'update seconds timer
End Sub

'********************Sub to draw the clock**************************
Sub hands(seconds As integer, minutes As integer, hours As integer, size As integer, x As integer, y As integer)'Sub to draw hands of clock
Local integer x1,y1,x2,y2,x0,y0,i
Local float angle=seconds*6
rotatetriangle(2,RGB(RED),angle,x,y,-3,50,3,50,-3,-size) 'make up the second hand with two triangles
rotatetriangle(3,RGB(RED),angle,x,y,3,-size,3,50,-3,-size*0.9)
angle=minutes*6 + seconds/10
rotatetriangle(0,RGB(BLACK),angle,x,y,-size/15,0,size/15,0,0,-size*0.9)
angle=hours*30 + minutes/2
rotatetriangle(1,RGB(BLACK),angle,x,y,-size/12,0,size/12,0,0,-size*0.7)
If first Then
i=triangles(nt, buff() , tcol(nt), xx0(nt), yy0(nt), xx1(nt), yy1(nt), xx2(nt), yy2(nt))
Print "Read buffer is ",i/buffersize*100,"% used"
first=0
Else
i=triangles(nt*2, buff() , tcol(), xx0(), yy0(), xx1(), yy1(), xx2(), yy2())
EndIf
Circle x,y, size\12, 0, , RGB(red), RGB(red))
Circle x,y, size\15, 0, , 0, 0
Circle x,y, size\20, 0, , RGB(gray), RGB(gray)
End Sub


Sub rotatetriangle(n As integer, col As integer, angle As float, x As integer, y As integer, x0 As integer, y0 As integer, x1 As integer, y1 As integer, x2 As integer, y2 As integer)
Local float sine=Sin(Rad(angle)),cosine=Cos(Rad(angle))
Local integer x0a,y0a,x1a,y1a,x2a,y2a
x0a= x0*cosine - y0 * sine + x
y0a= y0*cosine + x0 * sine + y
x1a= x1*cosine - y1 * sine + x
y1a= y1*cosine + x1 * sine + y
x2a= x2*cosine - y2 * sine + x
y2a= y2*cosine + x2 * sine + y
xx0(n)=xx0(n+nt)
yy0(n)=yy0(n+nt)
xx1(n)=xx1(n+nt)
yy1(n)=yy1(n+nt)
xx2(n)=xx2(n+nt)
yy2(n)=yy2(n+nt)
xx0(n+nt)=x0a
yy0(n+nt)=y0a
xx1(n+nt)=x1a
yy1(n+nt)=y1a
xx2(n+nt)=x2a
yy2(n+nt)=y2a
tcol(n)=-1
tcol(n+nt)=col
End Sub


'*************Matherp's subs and CFUNCTIONS to draw clock and .ppm pictures****************
sub mm.startup
  setrd(6)' set up the read pin
end sub

Csub setrd
   00000000
   27BDFFE8 AFBF0014 AFB00010 3C109D00 8C830000 8E020090 24050008 00003021  
   A043002D 8E030090 8E020010 0040F809 8064002D 8E030090 8E020010 24050065  
   8064002D 0040F809 00003021 8E030090 8E02001C 24050006 0040F809 8064002D  
   8FBF0014 8FB00010 03E00008 27BD0018  
End Csub

CFunction triangles '100 PIN
00000267
'defineregion
3C029D00 8C420090 24080100 3C03BF88 AC686434 80420015 2488FFFF 24A3FFFF
01064021 24060001 10460004 00671821 24060003 14460005 3C029D00 00805821
01005021 10000008 00602021 8C420094 00605821 00A05021 8C430000 2463FFFF
00682823 00642023 000B6202 000A4202 3C02BF88 24060200 24090100 00053A02
00041A02 35080300 358C0300 356B0300 240D022A AC4D6430 354A0300 AC466434
34E70300 AC466438 34A50300 AC496438 34630300 AC4C6430 34840300 AC466434
AC466438 AC4B6430 AC466434 AC466438 AC486430 2408022B AC466434 AC466438
AC4A6430 AC466434 AC466438 AC496434 AC486430 AC466434 AC466438 AC496438
AC476430 AC466434 AC466438 AC456430 AC466434 AC466438 AC436430 AC466434
AC466438 AC446430 AC466434 AC466438 03E00008 00000000
'writeRectangle
27BDFFD8 AFB40020 AFB3001C 00C0A021 00E09821 72749802 AFB00010 8FB00038
AFB20018 AFB10014 00109403 00108A03 AFBF0024 0411FFA4 00000000 3C02BF88
24030100 24040200 2405022C AC436434 36520300 AC456430 36310300 AC446434
36100300 AC446438 AC436438 1260000F 2673FFFF 24030200 2404FFFF 2673FFFF
AC526430 AC436434 AC436438 AC516430 AC436434 AC436438 AC506430 AC436434
AC436438 1664FFF6 2673FFFF 8FBF0024 8FB40020 8FB3001C 8FB20018 8FB10014
8FB00010 03E00008 27BD0028
'ReadRectangle
27BDFFC8 AFBF0034 AFBE0030 AFB7002C AFB60028 AFB50024 AFB40020 AFB3001C
AFB20018 3C139D00 AFB10014 AFB00010 8E630090 0080B021 8E620028 8064002D
00C0A821 00E0F021 00A0B821 0040F809 8FB10048 8E640090 8E630024 24050006
8084002D 24100001 0060F809 00508004 8E630090 00409021 8E620024 8064002D
24050005 0040F809 0015A040 0295A021 00409821 729E1002 02C02021 02E02821
02A03021 03C03821 0051A021 0411FF53 00000000 3C05BF88 24060100 ACA66434
8FA3004C 24070200 2402022E ACA26430 ACA76434 ACA76438 ACA66438 240600FF
00711821 3C02BF81 3C04BF88 ACA6641C AE700000 8C45F220 8C45F220 8C45F220
AE500000 8C866420 26310003 0234282B A0660000 AE700000 8C46F220 8C46F220
8C46F220 AE500000 8C866420 A0660001 AE700000 8C46F220 8C46F220 8C46F220
AE500000 8C866420 A0660002 14A0FFE8 24630003 3C02BF88 240300FF AC43641C
8FBF0034 02201021 8FBE0030 8FB7002C 8FB60028 8FB50024 8FB40020 8FB3001C
8FB20018 8FB10014 8FB00010 03E00008 27BD0038
'RestoreRectangle
27BDFFE0 AFB20018 AFB10014 00C09021 00E08821 72328802 AFB00010 AFBF001C
8FB00030 0411FF10 00000000 3C02BF88 24030100 24040200 2405022C AC436434
AC456430 AC446434 AC446438 AC436438 1220001D 2631FFFF 8FA40034 02202821
00902021 24030200 2407FFFF 80860000 24A5FFFF 34C60300 AC466430 AC436434
AC436438 80860001 34C60300 AC466430 AC436434 AC436438 80860002 24840003
34C60300 AC466430 AC436434 AC436438 54A7FFEF 80860000 00111040 26100003
00518821 02118021 8FBF001C 02001021 8FB20018 8FB10014 8FB00010 03E00008
27BD0020
'triangles
27BDFFA8 AFB20038 8FA3006C 00809021 8FA40074 AFBE0050 AFB7004C 0083102A
AFB3003C AFB10034 AFBF0054 AFB60048 AFB50044 AFB40040 AFB00030 00A09821
00C0B821 AFA70064 8FB10068 10400006 8FBE007C 02201021 AFA4006C 8FB10070
AFA30074 AFA20070 8FA30074 03C3102A 10400009 8FA6006C 8FA20070 8FA40078
AFBE0074 AFA20078 AFA40070 0060F021 8FA6006C 8FA30074 0066102A 50400008
8FA6006C 8FA40074 02201021 AFA60074 8FB10070 AFA4006C AFA20070 8FA6006C
14DE0036 8FA30074 8FA30070 0071102A 14400006 02203821 0223102A 10400005
8FA40078 10000002 8FA70070 8FB10070 8FA40078 0091102A 54400003 8FB10078
00E4102A 0082380B 1640000C 24020001 8FA5006C 24E70001 02202021 24060001
00F13823 AFB30010 AFB70014 0411FF16 00000000 100000B0 00409821 1642000C
8FA20064 8FA5006C 24E70001 02202021 24060001 00F13823 AFB30010 AFB70014
0411FF6E 00000000 100000A3 00409821 8FA5006C 24E70001 02202021 24060001
00F13823 AFA20010 AFB70014 0411FECB 00000000 10000099 8FBF0054 8FA4006C
007E1026 0002102B 00621023 AFA20020 0044102A 14400044 00808021 8FA60070
8FA20078 00641823 00D13023 00511023 03C42023 AFA60024 AFA20028 0000A021
0000A821 AFA30018 AFA4001C 24160001 8FA40018 8FA6001C 02002821 02A4001A
008001F4 02C03821 00001012 00511021 0286001A 00C001F4 00001812 00711821
0062302A 10C00003 00402021 00601021 00801821 24660001 00402021 16400009
00C23023 02002821 02C03821 AFB30010 AFB70014 0411FECC 00000000 10000012
00409821 5656000C 8FA20064 24630001 00402021 02002821 00623023 02C03821
AFB30010 AFB70014 0411FF24 00000000 10000005 00409821 AFB70014 AFA20010
0411FE86 00000000 8FA30020 8FA40024 8FA60028 26100001 0070102A 02A4A821
1040FFCB 0286A021 03D0102A 1440004A 8FA30070 8FA20078 8FA40074 8FA60078
00431023 AFA20024 8FA2006C 0204A023 00D13023 0202A823 8FA20024 70D5A802
03C41823 8FA4006C AFA60020 AFA30018 03C42023 AFA4001C 24160001 7054A002
8FA40018 8FA6001C 02002821 0284001A 008001F4 8FA40070 02C03821 00001012
00441021 02A6001A 00C001F4 00001812 00711821 0062202A 10800003 00403021
00601021 00C01821 24660001 00402021 16400009 00C23023 02002821 02C03821
AFB30010 AFB70014 0411FE7F 00000000 10000012 00409821 5656000C 8FA20064
24630001 00402021 02002821 00623023 02C03821 AFB30010 AFB70014 0411FED7
00000000 10000005 00409821 AFB70014 AFA20010 0411FE39 00000000 8FA30024
8FA40020 26100001 03D0102A 0283A021 1040FFCB 02A4A821 8FBF0054 02601021
8FBE0050 8FB7004C 8FB60048 8FB50044 8FB40040 8FB3003C 8FB20038 8FB10034
8FB00030 03E00008 27BD0058
'gettearscanline
27BDFFE0 AFBF001C AFB20018 AFB10014 AFB00010 3C109D00 8E030090 8E020028
0040F809 8064002D 8E030090 00409021 8E020024 8064002D 0040F809 24050006
8E030090 00408821 8E020024 8064002D 0040F809 24050005 24040001 3C03BF88
02449004 24060100 24070200 240500FF 24080245 AC666434 3C04BF81 AC686430
AC676434 AC676438 AC666438 AC65641C AC520000 8C86F220 8C86F220 8C86F220
8C86F220 AE320000 8C666420 AC520000 8C82F220 8C82F220 8C82F220 8C82F220
AE320000 8C626420 AC65641C 8FBF001C 30C400FF 00042200 304200FF 00821025
8FB20018 8FB10014 8FB00010 03E00008 27BD0020
'main
27BDFFB0 AFBE0048 AFB70044 AFB60040 8FBE0068 8FB7006C 8FB60070 AFB5003C
AFB40038 AFB1002C AFBF004C AFB30034 AFB20030 AFB00028 00808821 00A0A821
AFA60058 00E0A021 0411FFB0 00000000 2442FE70 2C42000A 1040FFFB 00000000
8E220000 184000A0 00008021 8FA20058 8C440004 04810025 8C470000 8FB20058
00001821 00001021 00008021 8FA40060 8FA50064 02834821 00834021 00A33021
02E32021 03C32821 02C31821 8D2C0000 8D0B0000 8CCA0000 8CA90000 8C880000
8C630000 24040001 00402821 02A03021 AFA30024 AFAC0010 AFAB0014 AFAA0018
AFA9001C AFA80020 0411FE7D 00000000 8E240000 26100001 0204202A 1480000E
001018C0 1000006A 00001021 8FA40058 001018C0 00831021 8C440004 8C470000
0480002A 00001021 26120001 001290C0 10000007 02009821 8E44000C 8E470008
0480FFD2 26520008 1000FFF1 8FA40058 8FA50060 8FA40064 02834821 00A34021
00833021 03C32821 02E32021 02C31821 8D2C0000 8D0B0000 8CCA0000 8CA90000
8C880000 8C630000 00002021 00402821 02A03021 AFA30024 AFAC0010 AFAB0014
AFAA0018 AFA9001C AFA80020 0411FE4C 00000000 8E240000 8FA50058 26730001
0264202A 1480000D 00B21821 8E230000 0203182A 10600036 8FA40058 001018C0
00832821 8CA40004 04800031 8CA70000 26120001 10000008 001290C0 8C640004
26450008 0480FFF1 8C670000 02401821 1000FFCF 00A09021 8FA50060 8FA40064
02834821 00A34021 00833021 03C32821 02E32021 02C31821 8D2C0000 8D0B0000
8CCA0000 8CA90000 8C880000 8C630000 24040002 00402821 02A03021 AFA30024
AFAC0010 AFAB0014 AFAA0018 AFA9001C AFA80020 0411FE1A 00000000 8E240000
8FA50058 26100001 0204202A 10800008 00B21821 8C640004 26450008 04800004
8C670000 02401821 1000FFDB 00A09021 8FBF004C 00021FC3 8FBE0048 000210C3
8FB70044 8FB60040 8FB5003C 8FB40038 8FB30034 8FB20030 8FB1002C 8FB00028
03E00008 27BD0050 1000FFF1 00001021
End CFunction


Trevor
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9063
Posted: 11:29pm 25 Jan 2020
Copy link to clipboard 
Print this post

  robert.rozee said  one piece of advice:

if you get stuck, walk away and take a break. do something trivial like washing the dishes, play a game of patience, or go for a drive or a walk. these things place your mind in a state where it can 'inadvertently' discover solutions.


cheers,
rob   :-)


TOTALLY agree with this.
There have been more situations then I can count, where my brain is tying itself in knots trying to work out why something that you think SHOULD work - WON'T work.

To paraphrase Rob, that is always when I get up and go and do something else as he says.  It DOES work.  Sometimes I find myself having a eureka moment while not even sitting at the computer, and you suddenly see what was going on, you come back and make the changes and it then works!

The moral of the story(as others have already said) is don't give up, BUT give yourself a mental break when you get stuck on something, as the more you push yourself to solve a problem that has you stuck, the more you tend to get your brain tied up in knots.
Smoke makes things work. When the smoke gets out, it stops!
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 12:14pm 26 Jan 2020
Copy link to clipboard 
Print this post

I wish I could help but I don't have an E100 any more
The only issue I can see is you're using CFunctions for the triangles
They are not needed in the later versions of MMBasic

From the manual
Drawing Commands
Compared to the standard Micromite the Micromite Plus has two additional basic drawing commands:
TRIANGLE X1, Y1, X2, Y2, X3, Y3, C, FILL
Draws a triangle with the corners at X1, Y1 and X2, Y2 and X3, Y3. C is the colour of the triangle and
FILL is the fill colour. FILL can omitted or be -1 for no fill.
 
TrevorH
Senior Member

Joined: 06/04/2018
Location: United Kingdom
Posts: 142
Posted: 01:38pm 26 Jan 2020
Copy link to clipboard 
Print this post

Hi Lewis,

I have sorted out the blit problem with the clock version you posted earlier that was supplied by Peter.
There were some omissions in that code and it doesn't blit just the pointers, it blits the whole clock.
But I still don't understand why the triangles version doesn't work as it should.

I had it working initially with a small amount of corruption where the hands swept, then suddenly the cpu exception appeared and back-tracking did not restore things.

It's just a mystery. I MUST be doing something wrong.

Will post a working blit clock if anyone is interested that works on E100, it is smaller than the original, mainly due to the lack of memory for the buffer.

Trevor
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8579
Posted: 07:18pm 26 Jan 2020
Copy link to clipboard 
Print this post

The attached definitely works on a E100 running latest firmware.
Load the code, then reset the CPU to execute the MM.STARTUP. Then RUN.
Alternatively save the CSUBS and MM.STARTUP in the library.

Either way setrd must be called from MM.startup before running the program and it can only be called once.

NB calls to RTC GETTIME are patched out as I don't have a clock attached



option explicit
option default none
const buffersize = 2500
dim integer buff(buffersize)
dim integer small,nt=4 'Number of triangles being updated
dim integer xx0(nt*2-1),yy0(nt*2-1),xx1(nt*2-1),yy1(nt*2-1),xx2(nt*2-1),yy2(nt*2-1),tcol(nt*2-1),secs,mins,hours,first=1
cls
small=mm.hres:if MM.VRES < small then small=mm.vres
'rtc gettime
settick 600000,timecorrect
load image "bigben.bmp",0,0
secs=val(right$(time$,2))
mins=val(mid$(time$,4,2))
hours=val(left$(time$,2))
do
 secs=val(right$(time$,2))
 mins=val(mid$(time$,4,2))
 hours=val(left$(time$,2))
 hands(secs,mins,hours,(small\2-small\12),small\2, small\2)
 do
 loop while val(right$(time$,2))=secs
loop
end
'
sub timecorrect
'  RTC gettime
end sub

Sub hands(seconds As integer, minutes as integer,  hours as integer, size as integer, x as integer, y as integer)  
   Local integer x1,y1,x2,y2,x0,y0,i
   local float angle=seconds*6
   rotatetriangle(2,RGB(RED),angle,x,y,-3,50,3,50,-3,-size) 'make up the second hand with two triangles
   rotatetriangle(3,RGB(RED),angle,x,y,3,-size,3,50,-3,-size)    
   angle=minutes*6 + seconds/10
   rotatetriangle(0,RGB(BLACK),angle,x,y,-size/15,0,size/15,0,0,-size*0.8)
   angle=hours*30 + minutes/2
   rotatetriangle(1,RGB(80,80,80),angle,x,y,-size/12,0,size/12,0,0,-size*0.5)
   if first then  
     i=triangles(nt, buff() , tcol(nt), xx0(nt), yy0(nt), xx1(nt), yy1(nt), xx2(nt), yy2(nt))  
     print "Read buffer is ",i/buffersize*100,"% used"
     first=0
   else
     i=triangles(nt*2, buff() , tcol(), xx0(), yy0(), xx1(), yy1(), xx2(), yy2())  
   endif
   Circle x,y, size\12, 0, , rgb(red), rgb(red))  
   Circle x,y, size\15, 0, , 0, 0  
   Circle x,y, size\20, 0, , RGB(gray), RGB(gray)  
End Sub    

sub rotatetriangle(n as integer, col as integer, angle as float, x as integer, y as integer, x0 as integer, y0 as integer, x1 as integer, y1 as integer, x2 as integer, y2 as integer)
  local float sine=sin(rad(angle)),cosine=cos(rad(angle))
  local integer x0a,y0a,x1a,y1a,x2a,y2a
  x0a= x0*cosine - y0 * sine + x
  y0a= y0*cosine + x0 * sine + y
  x1a= x1*cosine - y1 * sine + x
  y1a= y1*cosine + x1 * sine + y
  x2a= x2*cosine - y2 * sine + x
  y2a= y2*cosine + x2 * sine + y
  xx0(n)=xx0(n+nt)
  yy0(n)=yy0(n+nt)
  xx1(n)=xx1(n+nt)
  yy1(n)=yy1(n+nt)
  xx2(n)=xx2(n+nt)
  yy2(n)=yy2(n+nt)
  xx0(n+nt)=x0a  
  yy0(n+nt)=y0a
  xx1(n+nt)=x1a  
  yy1(n+nt)=y1a  
  xx2(n+nt)=x2a  
  yy2(n+nt)=y2a  
  tcol(n)=-1  
  tcol(n+nt)=col
end sub

CFunction triangles
   00000267
   'defineregion
   3C029D00 8C420090 24080100 3C03BF88 AC686434 80420015 2488FFFF 24A3FFFF
   01064021 24060001 10460004 00671821 24060003 14460005 3C029D00 00805821
   01005021 10000008 00602021 8C420094 00605821 00A05021 8C430000 2463FFFF
   00682823 00642023 000B6202 000A4202 3C02BF88 24060200 24090100 00053A02
   00041A02 35080300 358C0300 356B0300 240D022A AC4D6430 354A0300 AC466434
   34E70300 AC466438 34A50300 AC496438 34630300 AC4C6430 34840300 AC466434
   AC466438 AC4B6430 AC466434 AC466438 AC486430 2408022B AC466434 AC466438
   AC4A6430 AC466434 AC466438 AC496434 AC486430 AC466434 AC466438 AC496438
   AC476430 AC466434 AC466438 AC456430 AC466434 AC466438 AC436430 AC466434
   AC466438 AC446430 AC466434 AC466438 03E00008 00000000
   'writeRectangle
   27BDFFD8 AFB40020 AFB3001C 00C0A021 00E09821 72749802 AFB00010 8FB00038
   AFB20018 AFB10014 00109403 00108A03 AFBF0024 0411FFA4 00000000 3C02BF88
   24030100 24040200 2405022C AC436434 36520300 AC456430 36310300 AC446434
   36100300 AC446438 AC436438 1260000F 2673FFFF 24030200 2404FFFF 2673FFFF
   AC526430 AC436434 AC436438 AC516430 AC436434 AC436438 AC506430 AC436434
   AC436438 1664FFF6 2673FFFF 8FBF0024 8FB40020 8FB3001C 8FB20018 8FB10014
   8FB00010 03E00008 27BD0028
   'ReadRectangle
   27BDFFC8 AFBF0034 AFBE0030 AFB7002C AFB60028 AFB50024 AFB40020 AFB3001C
   AFB20018 3C139D00 AFB10014 AFB00010 8E630090 0080B021 8E620028 8064002D
   00C0A821 00E0F021 00A0B821 0040F809 8FB10048 8E640090 8E630024 24050006
   8084002D 24100001 0060F809 00508004 8E630090 00409021 8E620024 8064002D
   24050005 0040F809 0015A040 0295A021 00409821 729E1002 02C02021 02E02821
   02A03021 03C03821 0051A021 0411FF53 00000000 3C05BF88 24060100 ACA66434
   8FA3004C 24070200 2402022E ACA26430 ACA76434 ACA76438 ACA66438 240600FF
   00711821 3C02BF81 3C04BF88 ACA6641C AE700000 8C45F220 8C45F220 8C45F220
   AE500000 8C866420 26310003 0234282B A0660000 AE700000 8C46F220 8C46F220
   8C46F220 AE500000 8C866420 A0660001 AE700000 8C46F220 8C46F220 8C46F220
   AE500000 8C866420 A0660002 14A0FFE8 24630003 3C02BF88 240300FF AC43641C
   8FBF0034 02201021 8FBE0030 8FB7002C 8FB60028 8FB50024 8FB40020 8FB3001C
   8FB20018 8FB10014 8FB00010 03E00008 27BD0038
   'RestoreRectangle
   27BDFFE0 AFB20018 AFB10014 00C09021 00E08821 72328802 AFB00010 AFBF001C
   8FB00030 0411FF10 00000000 3C02BF88 24030100 24040200 2405022C AC436434
   AC456430 AC446434 AC446438 AC436438 1220001D 2631FFFF 8FA40034 02202821
   00902021 24030200 2407FFFF 80860000 24A5FFFF 34C60300 AC466430 AC436434
   AC436438 80860001 34C60300 AC466430 AC436434 AC436438 80860002 24840003
   34C60300 AC466430 AC436434 AC436438 54A7FFEF 80860000 00111040 26100003
   00518821 02118021 8FBF001C 02001021 8FB20018 8FB10014 8FB00010 03E00008
   27BD0020
   'triangles
   27BDFFA8 AFB20038 8FA3006C 00809021 8FA40074 AFBE0050 AFB7004C 0083102A
   AFB3003C AFB10034 AFBF0054 AFB60048 AFB50044 AFB40040 AFB00030 00A09821
   00C0B821 AFA70064 8FB10068 10400006 8FBE007C 02201021 AFA4006C 8FB10070
   AFA30074 AFA20070 8FA30074 03C3102A 10400009 8FA6006C 8FA20070 8FA40078
   AFBE0074 AFA20078 AFA40070 0060F021 8FA6006C 8FA30074 0066102A 50400008
   8FA6006C 8FA40074 02201021 AFA60074 8FB10070 AFA4006C AFA20070 8FA6006C
   14DE0036 8FA30074 8FA30070 0071102A 14400006 02203821 0223102A 10400005
   8FA40078 10000002 8FA70070 8FB10070 8FA40078 0091102A 54400003 8FB10078
   00E4102A 0082380B 1640000C 24020001 8FA5006C 24E70001 02202021 24060001
   00F13823 AFB30010 AFB70014 0411FF16 00000000 100000B0 00409821 1642000C
   8FA20064 8FA5006C 24E70001 02202021 24060001 00F13823 AFB30010 AFB70014
   0411FF6E 00000000 100000A3 00409821 8FA5006C 24E70001 02202021 24060001
   00F13823 AFA20010 AFB70014 0411FECB 00000000 10000099 8FBF0054 8FA4006C
   007E1026 0002102B 00621023 AFA20020 0044102A 14400044 00808021 8FA60070
   8FA20078 00641823 00D13023 00511023 03C42023 AFA60024 AFA20028 0000A021
   0000A821 AFA30018 AFA4001C 24160001 8FA40018 8FA6001C 02002821 02A4001A
   008001F4 02C03821 00001012 00511021 0286001A 00C001F4 00001812 00711821
   0062302A 10C00003 00402021 00601021 00801821 24660001 00402021 16400009
   00C23023 02002821 02C03821 AFB30010 AFB70014 0411FECC 00000000 10000012
   00409821 5656000C 8FA20064 24630001 00402021 02002821 00623023 02C03821
   AFB30010 AFB70014 0411FF24 00000000 10000005 00409821 AFB70014 AFA20010
   0411FE86 00000000 8FA30020 8FA40024 8FA60028 26100001 0070102A 02A4A821
   1040FFCB 0286A021 03D0102A 1440004A 8FA30070 8FA20078 8FA40074 8FA60078
   00431023 AFA20024 8FA2006C 0204A023 00D13023 0202A823 8FA20024 70D5A802
   03C41823 8FA4006C AFA60020 AFA30018 03C42023 AFA4001C 24160001 7054A002
   8FA40018 8FA6001C 02002821 0284001A 008001F4 8FA40070 02C03821 00001012
   00441021 02A6001A 00C001F4 00001812 00711821 0062202A 10800003 00403021
   00601021 00C01821 24660001 00402021 16400009 00C23023 02002821 02C03821
   AFB30010 AFB70014 0411FE7F 00000000 10000012 00409821 5656000C 8FA20064
   24630001 00402021 02002821 00623023 02C03821 AFB30010 AFB70014 0411FED7
   00000000 10000005 00409821 AFB70014 AFA20010 0411FE39 00000000 8FA30024
   8FA40020 26100001 03D0102A 0283A021 1040FFCB 02A4A821 8FBF0054 02601021
   8FBE0050 8FB7004C 8FB60048 8FB50044 8FB40040 8FB3003C 8FB20038 8FB10034
   8FB00030 03E00008 27BD0058
   'gettearscanline
   27BDFFE0 AFBF001C AFB20018 AFB10014 AFB00010 3C109D00 8E030090 8E020028
   0040F809 8064002D 8E030090 00409021 8E020024 8064002D 0040F809 24050006
   8E030090 00408821 8E020024 8064002D 0040F809 24050005 24040001 3C03BF88
   02449004 24060100 24070200 240500FF 24080245 AC666434 3C04BF81 AC686430
   AC676434 AC676438 AC666438 AC65641C AC520000 8C86F220 8C86F220 8C86F220
   8C86F220 AE320000 8C666420 AC520000 8C82F220 8C82F220 8C82F220 8C82F220
   AE320000 8C626420 AC65641C 8FBF001C 30C400FF 00042200 304200FF 00821025
   8FB20018 8FB10014 8FB00010 03E00008 27BD0020
   'main
   27BDFFB0 AFBE0048 AFB70044 AFB60040 8FBE0068 8FB7006C 8FB60070 AFB5003C
   AFB40038 AFB1002C AFBF004C AFB30034 AFB20030 AFB00028 00808821 00A0A821
   AFA60058 00E0A021 0411FFB0 00000000 2442FE70 2C42000A 1040FFFB 00000000
   8E220000 184000A0 00008021 8FA20058 8C440004 04810025 8C470000 8FB20058
   00001821 00001021 00008021 8FA40060 8FA50064 02834821 00834021 00A33021
   02E32021 03C32821 02C31821 8D2C0000 8D0B0000 8CCA0000 8CA90000 8C880000
   8C630000 24040001 00402821 02A03021 AFA30024 AFAC0010 AFAB0014 AFAA0018
   AFA9001C AFA80020 0411FE7D 00000000 8E240000 26100001 0204202A 1480000E
   001018C0 1000006A 00001021 8FA40058 001018C0 00831021 8C440004 8C470000
   0480002A 00001021 26120001 001290C0 10000007 02009821 8E44000C 8E470008
   0480FFD2 26520008 1000FFF1 8FA40058 8FA50060 8FA40064 02834821 00A34021
   00833021 03C32821 02E32021 02C31821 8D2C0000 8D0B0000 8CCA0000 8CA90000
   8C880000 8C630000 00002021 00402821 02A03021 AFA30024 AFAC0010 AFAB0014
   AFAA0018 AFA9001C AFA80020 0411FE4C 00000000 8E240000 8FA50058 26730001
   0264202A 1480000D 00B21821 8E230000 0203182A 10600036 8FA40058 001018C0
   00832821 8CA40004 04800031 8CA70000 26120001 10000008 001290C0 8C640004
   26450008 0480FFF1 8C670000 02401821 1000FFCF 00A09021 8FA50060 8FA40064
   02834821 00A34021 00833021 03C32821 02E32021 02C31821 8D2C0000 8D0B0000
   8CCA0000 8CA90000 8C880000 8C630000 24040002 00402821 02A03021 AFA30024
   AFAC0010 AFAB0014 AFAA0018 AFA9001C AFA80020 0411FE1A 00000000 8E240000
   8FA50058 26100001 0204202A 10800008 00B21821 8C640004 26450008 04800004
   8C670000 02401821 1000FFDB 00A09021 8FBF004C 00021FC3 8FBE0048 000210C3
   8FB70044 8FB60040 8FB5003C 8FB40038 8FB30034 8FB20030 8FB1002C 8FB00028
   03E00008 27BD0050 1000FFF1 00001021
End CFunction

sub mm.startup
 setrd(6) 'set up the pin connected to RD
end sub

Csub setrd
   00000000
   27BDFFE8 AFBF0014 AFB00010 3C109D00 8C830000 8E020090 24050008 00003021  
   A043002D 8E030090 8E020010 0040F809 8064002D 8E030090 8E020010 24050065  
   8064002D 0040F809 00003021 8E030090 8E02001C 24050006 0040F809 8064002D  
   8FBF0014 8FB00010 03E00008 27BD0018  
End Csub
 
TrevorH
Senior Member

Joined: 06/04/2018
Location: United Kingdom
Posts: 142
Posted: 12:40pm 27 Jan 2020
Copy link to clipboard 
Print this post

Hi Peter,

I think I have sorted what was wrong.

I had the RD pin set with option lcdpanel as for using blit and also did not hit reset
after loading code before running code.

After following these simple instructions it now works.

Can't recall using MMstartup before, you learn something everyday,

again thankyou.

Trevor
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 10:08am 17 Jan 2021
Copy link to clipboard 
Print this post

Does anyone know enough about Triangles to be able to tell me how to change the triangle from the small equilaterally sided one in blue
I basically need to know how to change Const side_length=17  so it has 3 sides of different lengths I guess

From this type



to the thin long sided type in red as shown below



This is the triangle code I'm using

Const pivot_x=cx%+15 'specIFy where the centre of the Compass dial is located
 Const pivot_y=cy%+16
 Const radius=wid%-4 'specIFy the radius of the compass dial
 Const side_length=17    'specify the size of the equilateral triangle pointer
 'define the points that make up the triangle relative to a pivot at 0,0
 Const x0=0
 Const x1=-side_length/2
 Const x2=side_length/2
 Const y0=-radius
 Const y1=-radius+side_length*Cos(Rad(30))
 Const y2=y1
 DIM integer angle, X, Y, W, H
 DIM integer xx0,xx1,xx2,yy0,yy1,yy2   'variables holding the vertices of the triangle relative to its pivot
 DIM integer pxx0,pxx1,pxx2,pyy0,pyy1,pyy2 'variables holding the absolute vertices of the triangle
 '
   'Subroutines to make the compass pointer move to the correct position thanks to Matherp
sub moveto(angle1 as integer)
 local integer xs=x, ys=y, ws=w, hs=h
 rotatetriangle(angle,0,radius,x0,y0,x1,y1,x2,y2)
 pxx0=xx0+pivot_x
 pyy0=yy0+pivot_y-radius
 pxx1=xx1+pivot_x
 pyy1=yy1+pivot_y-radius
 pxx2=xx2+pivot_x
 pyy2=yy2+pivot_y-radius
 getlimits(x, y, w, h)
 ' blit write and blit close first time in will error so skip
 ON ERROR SKIP 2
 BLIT WRITE #1, xs, ys 'restore the save background
 blit close #1
 blit read #1, x, y, w, h
 triangle pxx0, pyy0, pxx1, pyy1, pxx2, pyy2, RGB(BLUE),RGB(BLUE) 'COLOUR OF TRIANGLE
END sub
 '
sub getlimits(x as integer, y as integer, w as integer, h as integer)
 Local integer i,max_x=0,min_x=MM.HRES,max_y=0,min_y=MM.VRES
 IF(pxx0>max_x)THEN max_x=pxx0
 IF(pxx1>max_x)THEN max_x=pxx1
 IF(pxx2>max_x)THEN max_x=pxx2
 IF(pxx0<min_x)THEN min_x=pxx0
 IF(pxx1<min_x)THEN min_x=pxx1
 IF(pxx2<min_x)THEN min_x=pxx2
 IF(pyy0>max_y)THEN max_y=pyy0
 IF(pyy1>max_y)THEN max_y=pyy1
 IF(pyy2>max_y)THEN max_y=pyy2
 IF(pyy0<min_y)THEN min_y=pyy0
 IF(pyy1<min_y)THEN min_y=pyy1
 IF(pyy2<min_y)THEN min_y=pyy2
 x=min_x
 y=min_y
 w=max_x-min_x+2
 h=max_y-min_y+2
END sub
sub rotatetriangle(angle as float, x as integer, y as integer, x0 as integer, y0 as integer, x1 as integer, y1 as integer, x2 as integer, y2 as integer)
 local float sine=sin(rad(angle)),cosine=cos(rad(angle))
 local integer x0a,y0a,x1a,y1a,x2a,y2a
 x0a= x0*cosine - y0 * sine + x
 y0a= y0*cosine + x0 * sine + y
 x1a= x1*cosine - y1 * sine + x
 y1a= y1*cosine + x1 * sine + y
 x2a= x2*cosine - y2 * sine + x
 y2a= y2*cosine + x2 * sine + y
 xx0=x0a
 yy0=y0a
 xx1=x1a
 yy1=y1a
 xx2=x2a
 yy2=y2a
END sub
 '*******END of compass routine  *******************************
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 444
Posted: 12:29am 18 Jan 2021
Copy link to clipboard 
Print this post

Don't blame yourself.
Throw the first rock who has never lost a code for lack of backup.

I like to use github for my code backups and it's possible to automate the push process to send the commits to a second remote repo like bitbucket.
Edited 2021-01-18 16:40 by LeoNicolas
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 10:58am 18 Jan 2021
Copy link to clipboard 
Print this post

Edited:

Can anyone tell me how to change
This
 Const x1=-side_length/2
 Const x2=side_length/2
 Const y0=-radius
 Const y1=-radius+side_length*Cos(Rad(30))
 Const y2=y1

Where Const side_length is 17
to this format
TRIANGLE X1, Y1, X2, Y2, X3, Y3 [, C [, FILL]]
Where the radius of the circle is 105

and I want the pointer to be 2 pixels wide
Edited 2021-01-18 21:17 by lew247
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 844
Posted: 11:12am 18 Jan 2021
Copy link to clipboard 
Print this post

Hi Lewis,

The second hand is two long triangles back to back to give a rectangle, that is why 4 triangles. This post from Peter way back describes how to set them up.

How the triangles are defined

This could be a starting point.

Gerry
Latest F4 Latest H7
 
     Page 2 of 2    
Print this page


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

© JAQ Software 2024