Saturday, February 4, 2012

EVduino-MS-08beta-Code

Version EVduino-MS08 beta will include: 

  • 4 pcs. Voltage sensors for 4 x 12 volt 
  • 1 pcs. Low current sensor 30 amps, measure car energy consumption, headlights, instrument lights and so. NOT electric heater and The DC engine 
  • 1 pcs. High current sensor 300-400 amps for engine consumption and electric heater 
  • Temperature sensor for the DC engines coil temperature, code piece for dallas ds18b20

Startup coding the EVduino-MS-08beta

Starup with the code using the 2,8" LCD example from nuelectronic, and modify this to fit my application.


I used a hole week trying to place mesured data in one of the black text boxes shown on above picture.

Well, i don't think i can be done with text_box_p. Text_box_p is used to place static strings as the 'Batteries' on the screen.

I found that another lib must be used to place variables, the font lib.

Command used:

font.putChar('y')

Example: 



The code:

void batteriesvoltage()
{
       //exampel place qwerty in the drawn RoundRect
        char i = 22;
        char sensorData[20] = "qwertyuiopasdfghjkl";
     
uint8_t row=0;

// draw font
tft.ClearScreen(WHITE);

tft.DrawRoundRect( 40, 70, 280, 230,  10, MENU_HIGHLIGHT_COLOR,1);

font.set_Font(f15x22);
font.set_Color(MENU_FONT_COLOR, MENU_NORMAL_COLOR,1);

font.set_Cursor( 50, 80);

for(i=0; i<23;i++) //loop until al chrs in sensorData is placed on the LCD display
          {
            font.putChar(sensorData[i]); //place the sensorData variable, sensorData come from a sensor as voltage sensor, current sensor, temperature sensor
         
if(font.CharWidth(i) !=0)
{
if( (font.CursorX + font.CharWidth(i)) > 270)
{
row++;
font.set_Cursor(50, 80+ (row* font.Font_Height + 2));
}    
}
 }

font.set_Font(f12x12); // set font to menu size
wait_for_OK();

}

6 comments:

  1. I will follow your project, I bought a tft like yours from nuelectronics.

    I still can not display variables such as temperature value...

    ReplyDelete
    Replies
    1. hey, ;) i found that font.putChar is the way to place my own text at the LCD.

      I already have code pieces to sample temperature from dallas 1820 sensor. The code returns the ready sensor data to place at the LCD: font.putChar(sensorData[i]) (i is the char number)

      I will show this more detailed in this project, until then try look at this code:

      http://mynerdstuff.blogspot.com/2012/01/arduino-source-code-for-stokerarduino.html

      download the pdf and search for getCurrentTemp.

      the language is danish, sorry, in this EVduino project i will make comments to the code in english

      Delete
    2. so, now the temperature part works, you can check out the demo here: http://www.youtube.com/watch?v=UO9VySp6nCo

      and grab the megaduino / arduino demo code here:
      http://mynerdstuff.blogspot.com/2012/02/dallas-ds18b20-temperature-sensor-and.html

      have fun ;)

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. Hi,
    Nice site! I am loving it!! Will come back again ??taking you feeds also, Thanks.

    Dynamic balancing Machine

    ReplyDelete
  4. is there anyway to use the onewire / dallas libraries to use multiple ds18b20 sensors with your code?? love the idea.. just want to add more sensors.. and a RTC.. not sure i uderstand how you get the variables from the sensors into the display code!! (i am new to this so please forgive me!!)

    ReplyDelete