I want to log the light intensity at night over time and want to make a simple program which writes a 8x1 (pixels) line basically . And the line is 1 pixel wide and a max of 8 tall. I want to make it so over night lets say every 10 minutes it find the brightness maps it down between 0 and 8 and then writes it on the lcd. Anyone know how I can do this?
I wrote up a LCD bargraph for a sump well meter...
long and the short of it is I mapped the value over a 50 value range
bgLevel map(sumpLevel, sumpMin, SumpMax, BGMin, BGMax)
and then I drew a box using the GLCD.DrawRect for the outside of the graph, and then drew 2 consecutive GLCD.FillRects (one white, the value of the entire DrawRect in order to clear the previous value (and not do a complete GLCD.ClearScreen) and then the value fill, which was static X dimensions, and for the Y dimension - it subtracted the bgLevel from the bottom Y pixel (so the graph would fill from the bottom up), then left the remainder empty.
I don't have the code available to me now, and I taught my self all the C I know in the last two weeks...but it does exactly what I want, and it works well. I can put it in if you want, when I get home.
never mind...i got the VPN on my phone to work!
here's what I had
int barGraphValue(int cm){
/* This is purely for the gauge component of the display, the map command maps the values returned in cm
across the range of values for the sump bottom (limitSumpLo) to the sump overflow (limitSumpHi) to the
range of bar graph values for display.
*/
int barGraphMap = map(cm,limitSumpLo, limitSumpHi, barGraphMin, barGraphMax);
{
barGraphMap = constrain(barGraphMap, barGraphMin, barGraphMax);
}
return barGraphMap;
}
int drawBarGraph(int barGraphLevel){
GLCD.DrawRect(0,13,17,50, BLACK); // draw outline of bargraph
GLCD.FillRect(1,14,15,49, WHITE); //white out the entire thing
GLCD.FillRect(1,(63-barGraphLevel),15,(barGraphMin+barGraphLevel), BLACK); //draw new fill level
}
As I said before, I knew no C prior to two weeks ago...so this is all self taught, and I'm sure someone else out there can rip this apart in 5 minutes...but it works! ![]()
thebigphish:
never mind...i got the VPN on my phone to work!here's what I had
int barGraphValue(int cm){
/* This is purely for the gauge component of the display, the map command maps the values returned in cm
across the range of values for the sump bottom (limitSumpLo) to the sump overflow (limitSumpHi) to the
range of bar graph values for display.
*/
int barGraphMap = map(cm,limitSumpLo, limitSumpHi, barGraphMin, barGraphMax);
{
barGraphMap = constrain(barGraphMap, barGraphMin, barGraphMax);
}
return barGraphMap;
}
int drawBarGraph(int barGraphLevel){
GLCD.DrawRect(0,13,17,50, BLACK); // draw outline of bargraph
GLCD.FillRect(1,14,15,49, WHITE); //white out the entire thing
GLCD.FillRect(1,(63-barGraphLevel),15,(barGraphMin+barGraphLevel), BLACK); //draw new fill level
}
As I said before, I knew no C prior to two weeks ago...so this is all self taught, and I'm sure someone else out there can rip this apart in 5 minutes...but it works! :-)
wait wait wait, theres no void.setup or loop? how do i get an LDR to work with this?
wait wait wait, theres no void.setup or loop? how do i get an LDR to work with this?
It's just a function it's not the whole program. You have to do some of the work.
Don
thx floresta, forgot to mention it's a code snippet.