Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 12:31 19 May 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 : matherps clock code problem

Author Message
oldtimer
Newbie

Joined: 02/12/2016
Location: Australia
Posts: 18
Posted: 02:51pm 11 Feb 2017
Copy link to clipboard 
Print this post


Hi to all

Could anyone suggest a modification to the attached code - matherps "BIG BEN" , with the 100 pin MX 470 cfunction amendment and the "time update"added

My problem is - the bitmap image loads OK followed by a small circle edged in red in the centre of the image -(the second hand centre but without the attached hand)
but with nothing else - no hands!!

The frustrating thing is that when I first downloaded the code and added the modifications - using the "big ben.bmp" from my SD card - it actually worked - complete with moving hands- I then decided to use another BMP file on the SD card "clock1.bmp" which had loaded successfully many times using the "load image"command -but not in conjunction with the "BIG BEN " code - and hence the "clock1.bmp",157,5 ( to centre the display) in the attached file

That brought me to my present problem - the missing hands-and reverting back to the original code - using the "bigben.bmp" hasn't fixed the problem

Im attempting to run the code on an explore 100 with version 5.03 MMBASIC and a 5 inch SSD1963 display - hence the RD pin specified as - setrd(44) - Ive tried changing the pin number to other spare ANL/DIG pins but with no success

Another observation is that during numerous reloads - using MMEDIT- no fault is indicated after loading or when running the new reload -this makes it difficult to determine the problem as it appears that the reload was successful

Im sure that the problem is only some small part of the code - as evidenced by it working until the change of bitmap file and the dozens of photos of operating "BIG BEN' clocks on the forum

If anyone could suggest a fix - I would be most appreciative -code attached-



option explicit
option default none
const buffersize = 2500
dim integer buff(buffersize)
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
cls
load image "clock1.bmp",157,0
Circle MM.Hres\2, MM.Vres\2, (MM.Vres\2-MM.Vres\12)\12, 0, , rgb(red), rgb(red))
Circle MM.Hres\2, MM.Vres\2, (MM.Vres\2-MM.Vres\12)\15, 0, , 0, 0
Circle MM.Hres\2, MM.Vres\2, (MM.Vres\2-MM.Vres\12)\20, 0, , RGB(gray), RGB(gray)
do
secs=val(right$(time$,2))
mins=val(mid$(time$,4,2))
hours=val(left$(time$,2))
hands(secs,mins,hours,(MM.Vres\2-MM.Vres\12),MM.Hres\2, MM.Vres\2)
do
loop while val(right$(time$,2))=secs
loop

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(BLACK),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

sub mm.startup
setrd(44)' 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
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
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8605
Posted: 10:58pm 11 Feb 2017
Copy link to clipboard 
Print this post

setrd defines the pin that is connected to the RD pin on the display. Looking at the schematic for the Explore100 this is pin 6 so you must and can only use pin 6
 
oldtimer
Newbie

Joined: 02/12/2016
Location: Australia
Posts: 18
Posted: 01:08am 12 Feb 2017
Copy link to clipboard 
Print this post

Peter
Many thanks for the assistance - all running perfectly- for some reason- that I cant remember - I had added pin 6 to the end of "OPTION LCDPANEL" command -changing the command to "OPTION LCDPANEL SSD1963_5A,L,48" made everything happen as it should- thanks also for the realistic gauge program and bitmap using NON CFunction code -

please disregard my private mail to you relating to the above problem

Regards

Oldtimer
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8605
Posted: 01:30am 12 Feb 2017
Copy link to clipboard 
Print this post

  Quote  or some reason- that I cant remember - I had added pin 6 to the end of "OPTION LCDPANEL" command


You were getting stuck between 2 ways of doing the same thing.

Before 5.3 the Micromite firmware did not support using the RD pin on SSD1963 displays - it was normally pulled high. To read from the display required a CFunction which is what my code did.

Now in 5.3 the RD pin is supported and is used for the BLIT command, for transparent text, and for the PIXEL function.

The OPTION command in 5.3 is:

OPTION LCDPANEL SSD1963_x, orientation, backlight-pin, RD-pin

backlight-pin and RD-pin are optional. RD-pin is new for 5.3

To use the old CFunction RD-pin should NOT be specified
To use BLIT it MUST be specified

Hope this makes it clear.
 
Print this page


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

© JAQ Software 2024