Announcement
Collapse
No announcement yet.
Working with I2C Values and Widgets
Collapse
X
-
Not sure exactly, as the following line wont have 'quite' the effect, but moving this line
img_Show(hndl, iLeddigits1); // show all digits at 0, only do this once
to before the repeat will probably help a lot
-
Ugh, you are Right on, Thank you.
Any idea why the digits flash now?
The correct data shows in Bright green, but every repeat cycle all of the segments flash bright green (like an 8).
Even if I put in a delay(1000); all segments that should be off, flash briefly every cycle.
Thanks
Leave a comment:
-
At a quick glance you seem to be missing the very important lines
hndl := file_LoadImageControl("NoName1.dat", "NoName1.gci", 1);
Just before the repeat statement, which will, or course, need the filenames changing.
Leave a comment:
-
Working with I2C Values and Widgets
I am trying to display a value derived from I2C to a LED Digits Widget.
Having no luck. If I just Print the value it prints correctly but without the Print statement the program never runs, it just displays "Mounting" after inserting the Flash.
The print statement is at the end, commented out
My code is below. Any ideas what I am doing wrong?
One more thing? When Compiling & Loading, the IDE does not always ask for the Flash Drive with a pop-up, Sometimes yes, sometimes no. Why is this inconsistent?
Thanks
Code:#platform "uLCD-28PTU" #inherit "4DGL_16bitColours.fnc" #inherit "VisualConst.inc" #inherit "COOLGAUGE2Const.inc" #inherit "LEDDIGITSDISPLAY.INC" #constant device 0x80 #constant speed I2C_SLOW var data; var data1; var myTemp; var myTemp1; var myTempTot; var myTempC; var myRh; var myRhTot; var myRetTemp; var myRetRh; func receive() I2C_Open(speed); I2C_Start(); I2C_Write(device); I2C_Write(0xE5); I2C_Restart(); I2C_Write(device + 0x01); data:=I2C_Read(); I2C_Ack(); data1:=I2C_Read(); I2C_Nack(); I2C_Stop(); //I2C_Ack(); I2C_Start(); I2C_Write(device); I2C_Write(0xE0); I2C_Restart(); I2C_Write(device + 0x01); myTemp:=I2C_Read(); I2C_Ack(); myTemp1:=I2C_Read(); I2C_Nack(); I2C_Stop(); endfunc func RetTemp(var valin) var li[2] ; umul_1616(li, valin,17572) ; return li[1] - 4685 ; endfunc func RetRh(var valin) var li[2] ; umul_1616(li, valin,12500) ; return li[1] - 600 ; endfunc func main() // Uncomment the following if uSD images used. putstr("Mounting...\n"); if (!(disk:=file_Mount())) while(!(disk :=file_Mount())) putstr("Drive not mounted..."); pause(200); gfx_Cls(); pause(200); wend endif gfx_TransparentColour(0x0020); gfx_Transparency(ON); repeat receive(); myRhTot := (data<<8) + data1; myRetRh := RetRh(myRhTot); myTempTot := myTemp<<8 + myTemp1; myRetTemp := RetTemp(myTempTot); //print(myRetTemp); // Leddigits1 1.0 generated 2/25/2014 11:51:50 PM img_Show(hndl, iLeddigits1); // show all digits at 0, only do this once ledDigitsDisplay(myRetTemp, iLeddigits1+1, 20, 4, 1, 52, 0) ; forever endfunc
Tags: None
Leave a comment: