Pages: 1 2 3 [4]   Go Down
Author Topic: Hello, I need your help. can anyone have an example code for a graphical display  (Read 8341 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 36
I electronics
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, thank you for your explanation smiley.
Logged

Help me please

Offline Offline
Newbie
*
Karma: 0
Posts: 36
I electronics
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, I have two questions. How to make so I can come back from any of the programs back on the menu. I do not even appears on "goback".
program temperature sensor1 works not stable readings are flashing. I'll try to find out myself but also on aid will not give up. Thank you.
   
All the code does not fit  smiley-confuse. Please answer only if the first question.


Logged

Help me please

Germany
Offline Offline
Edison Member
*
Karma: 133
Posts: 1447
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

I have restructured your pde. My strong suggestion would be: Do not use GLCD directly, instead use m2tklib elements. I tried to mimic your GLCD output und transfered all to m2tklib code:


The code for this menu is quite simple and you still have a lot of features to control the output (".1" adds one digit after the comma, "f3" selects the big font, "c4" assigns 4 digits total)
Code:
M2_U32NUM(el_volt, ".1c5r1f3", &output_U1);
M2_LABEL(el_volt_label, NULL, "U.volt");
M2_U32NUM(el_ma, "c4r1f3", &output_amper);
M2_LABEL(el_ma_label, NULL, "mA");
M2_LIST(list_volt) = { &el_volt, &el_volt_label, &el_ma, &el_ma_label, &el_o1_go_back};
M2_GRIDLIST(top_el_volt, "c2", list_volt);

However, because of the PROGMEM feature discussed above, i modified m2tklib so you need an updated version (attached).

Please read your modified sourcecode. And please:
- Use m2tklib to output values
- Do not use delay()

Oliver
Code:
/*
  SensorValues.pde

*/

/*==========================================================================*/
/* Includes and menu key definition */
/*==========================================================================*/


#include <glcd.h>
#include "M2tk.h"
#include "utility/m2ghglcd.h"
//#include "m2ghglcd.h"

 unsigned long startMillis;
 
 float opn=4.99;     //??????? ?????????? ??????
 float volt;         // ?????????? ? ??????? ?????? ???????? ???????? ?????             
 float var0;            // ?????? ????????????? ???????? ?????, ?????? ? ????????? ????? No0 
 int amper ;          //?????????? ? ??????? ?????? ???????? ???????? ??????????.?????????? ????????????? ????????,? ?????? ??????? ??????????
 float var1  ;        // ?????? ????????????? ???????? ?????, ?????? ? ????????? ????? No1

//:: intoduced to communicate with m2tklib
uint32_t output_U1;
uint32_t output_amper;

//:: redefined to fit to my GLCD
uint8_t uiKeySelectPin = 3;
uint8_t uiKeyDownPin = 2;
uint8_t uiKeyUpPin = 1;
uint8_t uiKeyExitPin = 0;


/*==========================================================================*/
/* Sensor values: Will be set by some measurement processes  */
/*==========================================================================*/


//::  removed, was part of the example
uint32_t value1 = 1;
uint32_t value2 = 2;
uint32_t value3 = 3;


/*==========================================================================*/
/* Active sensor: Output variable by the menu, shows active dialog box  */
/*==========================================================================*/
/* 0: no sensor dialog open */
/* 1: sensor value 1 is on screen */
/* 2: sensor value 2 is on screen */
/* 3: sensor value 3 is on screen */
uint8_t active_sensor = 0;


/*==========================================================================*/
/* is_value_changed: Output variable by the sensor process */
/*==========================================================================*/
/* 0: value did not change */
/* 1: value has changed */
uint8_t is_value_changed = 0;


/*==========================================================================*/
/* Forward declaration of the menu class (required for the callback functions)  */
/*==========================================================================*/
extern M2tk m2;


/*==========================================================================*/
/* Hierachical menu, go back button for each sensor value dialog */
/*==========================================================================*/


/*=== Forward declaration of the root menu for option 1 ===*/
M2_EXTERN_VLIST(top_el);


/*=== "Go Back" button, which will be reused for option 1 example menu ===*/


void fn_o1_go_back(m2_el_fnarg_p fnarg) {
  active_sensor = 0;
  m2.setRoot(&top_el);
}
M2_BUTTON(el_o1_go_back, NULL, "Go Back", fn_o1_go_back);


/*=== Dialog boxes to show the values ===*/

M2_U32NUM(el_volt, ".1c5r1f3", &output_U1);
M2_LABEL(el_volt_label, NULL, "U.volt");
M2_U32NUM(el_ma, "c4r1f3", &output_amper);
M2_LABEL(el_ma_label, NULL, "mA");
M2_LIST(list_volt) = { &el_volt, &el_volt_label, &el_ma, &el_ma_label, &el_o1_go_back};
M2_GRIDLIST(top_el_volt, "c2", list_volt);


M2_LABEL(el_o1_v2_desc, NULL, "LITR:");
M2_U32NUM(el_o1_v2_num, ".1c5r2", &value2);
M2_LIST(list_o1_v2) = { &el_o1_v2_desc, &el_o1_v2_num, &el_o1_go_back};
M2_VLIST(el_o1_v2_vlist, NULL, list_o1_v2);


M2_LABEL(el_o1_v3_desc, NULL, "GRADUS:");
M2_U32NUM(el_o1_v3_num, ".1c6r3", &value3);
M2_LIST(list_o1_v3) = { &el_o1_v3_desc, &el_o1_v3_num, &el_o1_go_back};
M2_VLIST(el_o1_v3_vlist, NULL, list_o1_v3);


/*=== A parent selection box allows to select one of the sensor values ===*/


void fn_o1_select1(m2_el_fnarg_p fnarg) {
  active_sensor = 1;
  m2.setRoot(&top_el_volt);
}
M2_BUTTON(el_o1_select1, NULL, "VOLTMETER", fn_o1_select1);

void fn_o1_select2(m2_el_fnarg_p fnarg) {
  active_sensor = 2;
  m2.setRoot(&el_o1_v2_vlist);
}
M2_BUTTON(el_o1_select2, NULL, "FUEL", fn_o1_select2);

void fn_o1_select3(m2_el_fnarg_p fnarg) {
  active_sensor = 3;
  m2.setRoot(&el_o1_v3_vlist);
}
M2_BUTTON(el_o1_select3, NULL, "TEMPERATURE", fn_o1_select3);
M2_LIST(list_o1) = { &el_o1_select1, &el_o1_select2, &el_o1_select3 };
M2_VLIST(top_el, NULL, list_o1);

/*==========================================================================*/
/* Menu constructor */
/*==========================================================================*/

M2tk m2(&top_el, m2_es_arduino, m2_eh_2bs, m2_gh_glcd_uffs);
 
/*==========================================================================*/
/* Sensor process */
/*==========================================================================*/

void volt_process(void) {
  //:: introduce a temp variable, for the update flag
  uint32_t tmp;
 
  //:: avoid output to GLCD (conflicts with m2tklib), also use a separate process
  // GLCD.Init(NON_INVERTED);
  // GLCD.ClearScreen();
  // GLCD.SelectFont((const uint8_t *)m2_System5x7);
  // gText s1;gText s2;
 
  //:: do not do any delays within the sensor process. It should return immediatly
  // startMillis = millis();
  // while( millis() - startMillis < 1000){
 
  //:: again: do not do output to the GLCD directly
    // s1.DefineArea(textAreaTOP);
    // s1.SelectFont(fixednums15x31);
    // s2.DefineArea(textAreaTOP);
    // s2.SelectFont(fixednums15x31);
    var0 = analogRead(0); 
    volt =(opn*var0/1024.0);
    //:: value of U1 will be output on the screen. This should be done by m2tklib, so additionaly create output_U1
    float U1;
    U1=volt*((8200.0+1860.0)/1860.0)/2;  //(opn*var1/1024.0)
 
    //:: output_U1 is uint32_t, use "*10" to have one digit after the comma.
    tmp = U1*10.0;
    if ( output_U1 != tmp )
    {
      output_U1 = tmp;
      is_value_changed = 1;
    }
   
    //:: Analog 1 is used by my GLCD
    //var1 = analogRead(1);
    float amper =((opn*var1/1.0240)/.50);
   
    //:: same applies to "amber". I will introduce an uint32_t for the output of the amber value.
    tmp = amper;
    if ( output_amper != tmp )
    {
      output_amper = tmp;
      is_value_changed = 1;
    }
    //:: remaining things are done by m2tklib
    // s1.CursorTo(0,0);
    // s1.print(U1); 
   
    // GLCD.SelectFont((const uint8_t *)m2_Arial14);
    // GLCD.CursorTo(8,1);
    // GLCD.Puts("U.volt");
    // s2.CursorTo(0,1);
    // s2.print(amper);
    // GLCD.SelectFont((const uint8_t *)m2_Arial14);
    // GLCD.CursorTo(8,3);
    // GLCD.Puts("mA");
   
    // delay(300);
  // }
}

/* sensor3 process assignes a 1/10 seconds since reset */
void sensor3_process(void) {
  uint32_t tmp;
  /* just assign the 1/10 seconds since last reset */
  tmp = millis();
  tmp /= 100;
  if ( value3 != tmp ) {
    value3 = tmp;
    is_value_changed = 1;
  }
}

/* reads active_sensor and writes values to "value1", "value2" or "value3" */
void sensor_process(void)
{
  switch(active_sensor) {
    case 1:
      volt_process();
      break;
    case 2:
      break;
    case 3:
      break;
    default:
      break;
  }
}


/*==========================================================================*/
/* Arduino setup & loop */
/*==========================================================================*/


void setup() {
  pinMode(12, OUTPUT);
  //:: pin 9 is used by my GLCD
  // pinMode(9, OUTPUT);     
  m2.setPin(M2_KEY_SELECT, uiKeySelectPin);
  m2.setPin(M2_KEY_NEXT, uiKeyDownPin);
  m2.setPin(M2_KEY_PREV, uiKeyUpPin);
  m2.setPin(M2_KEY_EXIT, uiKeyExitPin); 
 
  // font 0 is for nomal text s
  m2.setFont(0, m2_System5x7);
  // font 3 a big sensor values
  //m2.setFont(3, m2_System5x7);
  m2.setFont(3, m2_fixednums7x15);
}


void loop() {
  m2.checkKey();
  if ( m2.handleKey() || is_value_changed ) {
      m2.draw();
      is_value_changed = 0;
  }
 
  sensor_process();
}

* m2tklib_arduino_glcd_1.03pre1.zip (125.43 KB - downloaded 17 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
I electronics
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you very much. You helped me a lot. smiley
Logged

Help me please

Offline Offline
Newbie
*
Karma: 0
Posts: 36
I electronics
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, I'm not comfortable asking you yet. smiley-red We can make big numbers fixednums15x31. I just have a second program are displayed, fuel level of graphics. Code below to program fuel.
Code:
//   Fuel Meter v1.0
// Author : Robotix & RJ
// Date: 21 November 2010
// Property of : ROBOMODS
#include "glcd.h"
#include "fonts/allFonts.h"
const int analogPin = 0;     // potentiometer wiper (middle terminal) connected to analog pin 3
                     // outside leads to ground and +5V
int raw = 0;                 // variable to store the raw input value
int Vin = 5;                 // variable to store the input voltage
float Vout = 0;              // variable to store the output voltage
float R1 = 48;               // variable to store the R1 value
float R2 = 0;                // variable to store the R2 value
float buffer = 0;            // buffer variable for calculation
const int ledMediumL = 7;   // Lower Range Value for Medium Fuel
const int ledMediumH = 48;   // Upper Range Value for Medium Fuel
const int ledPin = 12;      // Set Medium Fuel LED to Pin 12
const int ledLowH = 4;      // Upper Range Value for Low Fuel (Anything below this is obviously Low Fuel)
const int ledPin2 = 2; // Set Low Fuel LED to Pin 2
long lastsec = 1; // must be different from sec for initial update

void setup()
{ GLCD.Init(NON_INVERTED);
  GLCD.ClearScreen();
 
  Serial.begin(9600);             // Setup serial         
  pinMode(ledPin, OUTPUT);        // Set Medium Fuel LED Pin to OUTPUT
  pinMode(ledPin2, OUTPUT);        // Set Low Fuel LED Pin to OUTPUT
}
void BarGraph(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t fullval, uint8_t currentval){
unsigned int currentwidth = currentval * width / fullval;
#ifdef SAMPLE_MAP
unsigned int currentwidth = map(currentval, 0, fullval, 0, width);
#endif

GLCD.DrawRect(x, y, width, height); // draw boarder
GLCD.FillRect(x, y, currentwidth, height); // draw left "busy" part
GLCD.FillRect(x+currentwidth+1, y+1, width-currentwidth-2, height-2, WHITE); // clear right part
}

gText t1; // will define runtime later

#if DISPLAY_HEIGHT > 32

#endif


void loop()
{
  int raw = analogRead(analogPin);    // Reads the Input PIN
  Vout = ((5.0 / 5115.0) * raw);    // Calculates the Voltage on the Input PIN
  buffer = (Vin / Vout) - 1;     
  R2 = R1 / buffer;
  R2 = R2 * 4;
  Serial.print("Resistance: ");           // Prints the Resistance Label
  Serial.println(R2);
        t1.DefineArea(textAreaTOP);
t1.SelectFont(fixednums15x31);  // Prints the Resistance Value
     t1.CursorToXY(0,0);
     
     t1.print(R2);
     BarGraph(10, 40, 108, 16, 59, R2);
     lastsec = R2; // save last update time
     GLCD.SelectFont(System5x7);
     GLCD.CursorTo(0,6);//ставим курсор в позицию
     GLCD.Puts("L");
     GLCD.CursorTo(18,6);//ставим курсор в позицию
     GLCD.Puts("H");
     
     
     
 
if (R2 > ledMediumL) {                 // Check if Fuel is within Medium Range
  if (R2 < ledMediumH) {                // Checl if Fuel is within Medium Range
   digitalWrite(ledPin, HIGH);           // It is so turn on Medium Fuel LED
   Serial.print("Medium Fuel! ");        // Tell the Console
}
   else {
     digitalWrite(ledPin, LOW);           // It isn't so make sure the Medium Fuel LED is OFF
}
  }
  else {
    digitalWrite(ledPin, LOW);           // It isn't so make sure the Medium Fuel LED is OFF
    if (R2 <= ledLowH) {              // Check if fuel is below the Low Fuel Threshold
      digitalWrite(ledPin2, HIGH);        // It is so turn on the Low Fuel LED
      Serial.print("Low Fuel! ");        // Tell the Console
    }
    else {
      digitalWrite(ledPin2, LOW);         // It isn't so make sure the Low Fuel LED is OFF
    }
}

  delay(1000);                       // Pause to allow for more accurate reading
}
Logged

Help me please

Germany
Offline Offline
Edison Member
*
Karma: 133
Posts: 1447
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

I have attached pre2 of m2tklib. It includes the new label m2_fixednums15x3, which can be
used to assign the font to some index:
  m2.setFont(2, m2_fixednums15x31);

You can select this font by using f2 (where 2 is the index)
  M2_U32NUM(el_volt, ".1c5r1f2", &output_U1);

Note: M2tklib v1.03pre2 has not been tested very much.

Oliver

* m2tklib_arduino_glcd_1.03pre2.zip (125.45 KB - downloaded 14 times.)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
I electronics
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As always, thank you very much dear olikraus . smiley
Logged

Help me please

Offline Offline
Newbie
*
Karma: 0
Posts: 36
I electronics
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, tell me how to get the temperature from the sensor on the graphic screen. I have something that does not work. I can not back when you return to the menu. What am I doing wrong please help. smiley-confuse
I do not understand why I can not send the entire code. smiley-cry

Code:
#include "glcd.h"
#include "fonts/allFonts.h"
#include "M2tk.h"
#include "utility/m2ghglcd.h"
#include <Bounce.h>
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 3
#define TEMPERATURE_PRECISION 9

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);

// arrays to hold device addresses
DeviceAddress insideThermometer, outsideThermometer;
// function that will be called when an alarm condition exists during DallasTemperatures::processAlarms();
void newAlarmHandler(uint8_t* deviceAddress)
{
  Serial.println("Alarm Handler Start");
  printAlarmInfo(deviceAddress);
  printTemp(deviceAddress);
  Serial.println();
  Serial.println("Alarm Handler Finish");
}

void printCurrentTemp(DeviceAddress deviceAddress)
{
  printAddress(deviceAddress);
  printTemp(deviceAddress);
  Serial.println();
}

void printAddress(DeviceAddress deviceAddress)
{
  Serial.print("Address: ");
  for (uint8_t i = 0; i < 8; i++)
  {
    if (deviceAddress[i] < 16) Serial.print("0");
    Serial.print(deviceAddress[i], HEX);
  }
  Serial.print(" ");
}

void printTemp(DeviceAddress deviceAddress)
{
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC != DEVICE_DISCONNECTED)
  {
    Serial.print("Current Temp C: ");
    Serial.print(tempC);
  }
  else Serial.print("DEVICE DISCONNECTED");
  Serial.print(" ");
}

void printAlarmInfo(DeviceAddress deviceAddress)
{
  char temp;
  printAddress(deviceAddress);
  temp = sensors.getHighAlarmTemp(deviceAddress);
  Serial.print("High Alarm: ");
  Serial.print(temp, DEC);
  Serial.print("C");
  Serial.print(" Low Alarm: ");
  temp = sensors.getLowAlarmTemp(deviceAddress);
  Serial.print(temp, DEC);
  Serial.print("C");
  Serial.print(" ");
}




//#include "m2ghglcd.h"

 unsigned long startMillis;
 
 
 
 
//:: intoduced to communicate with m2tklib
uint32_t output_U1;
uint32_t output_amper;
uint32_t output_L1;
uint32_t output_L2;
uint32_t output_tempC;

//:: redefined to fit to my GLCD
uint8_t uiKeySelectPin = 40;
uint8_t uiKeyDownPin = 41;
uint8_t uiKeyUpPin = 38;
uint8_t uiKeyExitPin = 39;
//::  removed, was part of the example
uint32_t value1 = 1;
uint32_t value2 = 2;
uint32_t value3 = 3;
uint32_t value4 = 4;
uint32_t value5 = 5;
/* 0: no sensor dialog open */
/* 1: sensor value 1 is on screen */
/* 2: sensor value 2 is on screen */
/* 3: sensor value 3 is on screen */
uint8_t active_sensor = 0;
/* 0: value did not change */
/* 1: value has changed */
uint8_t is_value_changed = 0;

extern M2tk m2;

/*=== Forward declaration of the root menu for option 1 ===*/
  M2_EXTERN_VLIST(top_el);


/*=== "Go Back" button, which will be reused for option 1 example menu ===*/

  void fn_o1_go_back(m2_el_fnarg_p fnarg) {
  active_sensor = 0;
  m2.setRoot(&top_el);
}
M2_BUTTON(el_o1_go_back, NULL, "Go Back", fn_o1_go_back);


/*=== Dialog boxes to show the values ===*/



M2_U32NUM(el_li3, ".1c4r1f2", &output_tempC);
M2_LIST(list_o1_v5) = { &el_li3,  &el_o1_go_back};
M2_VLIST(el_o1_v5_vlist, NULL, list_o1_v5);
/*=== A parent selection box allows to select one of the sensor values ===*/


        void fn_o1_select1(m2_el_fnarg_p fnarg) {
       active_sensor = 1;
           m2.setRoot(&top_el_volt);
             }
void fn_o1_select5(m2_el_fnarg_p fnarg) {
  active_sensor = 5;
  m2.setRoot(&el_o1_v5_vlist);
}
M2_BUTTON(el_o1_select5, NULL, "TEMPERATURE", fn_o1_select5);
M2_LIST(list_o1) = { &el_o1_select1, &el_o1_select2, &el_o1_select3 , &el_o1_select4 , &el_o1_select5 };
M2_VLIST(top_el, NULL, list_o1);
M2tk m2(&top_el, m2_es_arduino, m2_eh_4bs, m2_gh_glcd_uffs);
 
void volt_process(void) { //I can not send all the code. So cut.
  }
   
/* fuel process. */
void celsi_process(void) {
 
void lever_process(void) { 
}
 
void temper_process(void) {
  uint32_t tmp;
   
  // ask the devices to measure the temperature
  sensors.requestTemperatures();
 
  // if an alarm condition exists as a result of the most recent
  // requestTemperatures() request, it exists until the next time
  // requestTemperatures() is called AND there isn't an alarm condition
  // on the device
  if (sensors.hasAlarm())
  {
    Serial.println("Oh noes!  There is at least one alarm on the bus.");
  }

  // call alarm handler function defined by sensors.setAlarmHandler
  // for each device reporting an alarm
  sensors.processAlarms();

  if (!sensors.hasAlarm())
  {
    // just print out the current temperature
    printCurrentTemp(insideThermometer);
    printCurrentTemp(outsideThermometer);
  }
  float tempC;
   tmp = tempC;
    if ( output_tempC != tmp )
    {
      output_tempC = tmp;
      is_value_changed = 1;
  delay(50);
 
}
}
/* reads active_sensor and writes values to "value1", "value2" or "value3" */
void sensor_process(void)
{
  switch(active_sensor) {
    case 1:
      volt_process();
      break;
    case 2:
      break;
    case 3:
    celsi_process();
      break;
    case 4:
    lever_process();
    break;
   case 5:
    temper_process();
   
    default:
      break;
  }
}
void setup() {
 
   // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

  // Start up the library
  sensors.begin();
 
  // locate devices on the bus
  Serial.print("Found ");
  Serial.print(sensors.getDeviceCount(), DEC);
  Serial.println(" devices.");

  // search for devices on the bus and assign based on an index
  if (!sensors.getAddress(insideThermometer, 0)) Serial.println("Unable to find address for Device 0");
  if (!sensors.getAddress(outsideThermometer, 1)) Serial.println("Unable to find address for Device 1");

  Serial.print("Device insideThermometer ");
  printAlarmInfo(insideThermometer);
  Serial.println();
 
  Serial.print("Device outsideThermometer ");
  printAlarmInfo(outsideThermometer);
  Serial.println();
 
  // set alarm ranges
  Serial.println("Setting alarm temps...");
  sensors.setHighAlarmTemp(insideThermometer, 61);
  sensors.setLowAlarmTemp(insideThermometer, 91);
  sensors.setHighAlarmTemp(outsideThermometer, 60);
  sensors.setLowAlarmTemp(outsideThermometer, 90);
 
  Serial.print("New insideThermometer ");
  printAlarmInfo(insideThermometer);
  Serial.println();
 
  Serial.print("New outsideThermometer ");
  printAlarmInfo(outsideThermometer);
  Serial.println();

  // attach alarm handler
  sensors.setAlarmHandler(&newAlarmHandler);

  m2.setPin(M2_KEY_SELECT, uiKeySelectPin);
  m2.setPin(M2_KEY_NEXT, uiKeyDownPin);
  m2.setPin(M2_KEY_PREV, uiKeyUpPin);
  m2.setPin(M2_KEY_EXIT, uiKeyExitPin); 
 
  // font 0 is for nomal text s
  m2.setFont(0, m2_System5x7);
  // font 3 a big sensor values
  //m2.setFont(3, m2_System5x7);
  m2.setFont(2, m2_fixednums15x31);
 
  pinMode(switchPin4, INPUT); //dipped headlights
  pinMode(ledPin4, OUTPUT);
 
  pinMode(BUTTON,INPUT);//High beams
  pinMode(LED,OUTPUT);
   
 
  pinMode(controlPin, OUTPUT);
  pinMode(ledPin, OUTPUT);        // Set Medium Fuel LED Pin to OUTPUT
  pinMode(ledPin2, OUTPUT);   // Set Low Fuel LED Pin to OUTPUT
}
boolean debounce(boolean last)
{
  boolean current =digitalRead(switchPin4 );
  if (last !=current)
  {
    delay(5);
    current = digitalRead(switchPin4 );
  }
  return current;
}

   void BarGraph(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t fullval, uint8_t currentval){
   GLCD.Init(INVERTED);
unsigned int currentwidth = currentval * width / fullval;
#ifdef SAMPLE_MAP
unsigned int currentwidth = map(currentval, 0, fullval, 0, width);
#endif
       
GLCD.DrawRect(x, y, width, height); // draw boarder
GLCD.FillRect(x, y, currentwidth, height); // draw left "busy" part
GLCD.FillRect(x+currentwidth+1, y+1, width-currentwidth-2, height-2, WHITE); // clear right part
}
void loop() {
  if ( bouncer.update() ) {
     if ( bouncer.read() == HIGH) {
       if ( ledValue == LOW ) {
         ledValue = HIGH;
       } else {
         ledValue = LOW;
       }
       digitalWrite(LED,ledValue);
     }
   }
   currentButton = debounce(lastButton);
  if (lastButton == LOW && currentButton == HIGH)
  {
    ledOn =!ledOn;
  }
  lastButton = currentButton;
  digitalWrite(ledPin4, ledOn);
   
  m2.checkKey();
  if ( m2.handleKey() || is_value_changed ) {
      m2.draw();
      is_value_changed = 0;
  }
 
  sensor_process();
}
Logged

Help me please

Germany
Offline Offline
Edison Member
*
Karma: 133
Posts: 1447
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi


Quote
I do not understand why I can not send the entire code.

You could use the "additional options..." and attach your .pde file.

Quote
tell me how to get the temperature from the sensor on the graphic screen

Which is the variable which holds the temperature value?
I am a little bit confused about the source. Maybe you cut some important parts.
Maybe you can attach the whole source.

Oliver
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
I electronics
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello, thank you. I have attached a file pde. It is completely code. If you're wondering what I can tell you that this will be my first on-board computer. I have a very old mazda323 1986 all wiring is very old and puts stress. The engine cooling fan is working badly. And Money on another machine there. So I decided to put this device. temperature sensor on the idea of ​two wanted to put it. in a salon in another engine. but still wanted to look at one.

* on_board_computer_1.pde (16.16 KB - downloaded 16 times.)
Logged

Help me please

Germany
Offline Offline
Edison Member
*
Karma: 133
Posts: 1447
If you believe something is right, you won't see what's wrong (David Straker).
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A real cool application. A nice project.

I have checked your source. And the code seems to be fine for me.
Maybe you could more detailed specify what you expect and what is wrong with your code.
I could help better if you could describe the problem more detailed.

You mentioned the temperature:
active_sensor is set to 5, fine
output_tempC is set, however the delay(1000) will freeze your display for 1 second!

Are other sensors working? Is your menu ok?

Oliver

Oliver

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 36
I electronics
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for responding so quickly. smiley but of course I'll describe in more detail. So that should make the program.
1. measure the voltage
2. show the level of fuel
at residue 4 liters include LED HL1 (RED)
when 7 or more liters to include HL2 (green) and off HL1
3. a temperature sensor indicates the temperature in the cabin
4. second temperature sensor for the engine. I therefore chose the example of a library ALARM HANDLER
when the 90-degree turn on the fan radiator cooling the engine. When the temperature drops to 60 degrees off.
5. inclusion dipped
6. inclusion of headlamps.

While there is no more ideas. Thank you very much for your help.
Logged

Help me please

Offline Offline
Newbie
*
Karma: 0
Posts: 36
I electronics
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You mentioned the temperature:
active_sensor is set to 5, fine
output_tempC is set, however the delay(1000) will freeze your display for 1 second!

Yes you are correct delay of 1 second is a lot. Better without delay. And the problem is that I can not take the temperature reading on the GLCD screen. What goes wrong in the menu click the temperature. With all the computer turns on but does not show the GLCD. And when you I can not go back on the menu.
Logged

Help me please

Pages: 1 2 3 [4]   Go Up
Jump to: