Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: F7_Ethernet mbed MbedJSONValue LCD_DISCO_F746NG mbed-rtos BSP_DISCO_F746NG CANMsg NetworkAPI SDFileSystem_Warning_Fixed GroveStreamsmodified LcdDiscoF746NgTracer JSON
Revision 17:f3c5ec9ca00f, committed 2021-01-13
- Comitter:
- 38domo
- Date:
- Wed Jan 13 19:52:35 2021 +0000
- Branch:
- jpa
- Parent:
- 16:f0d946e6da36
- Commit message:
- version 12/01 without ethernet, only tasmota wifi and can
Changed in this revision
--- a/GroveStreams.lib Wed Dec 30 17:22:27 2020 +0000 +++ b/GroveStreams.lib Wed Jan 13 19:52:35 2021 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/38domo/code/GroveStreamsmodified/#b77ba7f2611b +https://os.mbed.com/users/38domo/code/GroveStreamsmodified/#494da6893902
--- a/GuiJPA.cpp Wed Dec 30 17:22:27 2020 +0000
+++ b/GuiJPA.cpp Wed Jan 13 19:52:35 2021 +0000
@@ -1,5 +1,4 @@
-/*
-
+/*
var LCD_COLOR_BLUE = "0xFF0000FF";
var LCD_COLOR_GREEN = "0xFF00FF00";
var LCD_COLOR_RED = "0xFFFF0000";
@@ -28,18 +27,17 @@
var LCD_COLOR_TRANSPARENT = "0xFF000000";
*/
-
#include "stm32746g_discovery_lcd.h"
#include "stm32746g_discovery_ts.h"
#include "MbedJSONValue.h"
#include "GroveStreams.h"
-#include <string>
+//#include <string>
int touchButtonJPA1(int numButton);
extern uint32_t backColorButton[5];
extern uint32_t txtColorButton[5];
char textButton[5][30];
- char text1Button[5][30];
+char text1Button[5][30];
extern char statusButton[5][30];
extern int ethernet_actif ; // use ethernet connection
@@ -47,11 +45,21 @@
uint32_t backColorTemp1=LCD_COLOR_BLACK, txtColorTemp1=LCD_COLOR_GREEN;
uint32_t backColorTemp2=LCD_COLOR_BLACK, txtColorTemp2=LCD_COLOR_GREEN;
+int xTempTitle[3],yTempTitle[3],dxTempTitle[3],dyTempTitle[3],xTxtTempTitle[3],yTxtTempTitle[3];
+uint32_t backColorTempTitle[3], txtColorTempTitle[3];
+char textTempTitle[3][30];
+// GroveStreams Settings
+extern const char gsApiKey[] = "YOUR_SECRET_API_KEY_HERE"; //Change This!!!
+extern const char gsCompName[] = "STM32F746+Discovery"; //Optionally change. Set this to give your component a name when it initially registers. Encode special chars such as spaces.
+extern const char gsCompTmplId[]= ""; //Optional. Tells GS what template to use when the feed initially arrives and a new component needs to be created.
+////GroveStreams groveStreams(gsApiKey, &lcd);
+//extern GroveStreams groveStreams;
+extern const char* myMac;
+int displayOn = 0;
// ----------------------------------------------------
int setTemp1(std::string temp1)
- {
- printf("\nTemp1 : %s\n", temp1.c_str());
+ { printf("\nTemp1 : %s\n", temp1.c_str());
BSP_LCD_SetBackColor(backColorTemp1);
BSP_LCD_SetTextColor(txtColorTemp1);
BSP_LCD_SetFont(&FontFreeMono64);
@@ -61,8 +69,7 @@
}
// ------------------------------------------------
int setTemp2(std::string temp2)
- {
- printf("\nTemp2 : %s\n", temp2.c_str());
+ { printf("\nTemp2 : %s\n", temp2.c_str());
BSP_LCD_SetBackColor(backColorTemp2);
BSP_LCD_SetTextColor(txtColorTemp2);
BSP_LCD_SetFont(&FontFreeMono64);
@@ -71,16 +78,11 @@
return 1;
}
-int xTempTitle[3],yTempTitle[3],dxTempTitle[3],dyTempTitle[3],xTxtTempTitle[3],yTxtTempTitle[3];
-uint32_t backColorTempTitle[3], txtColorTempTitle[3];
-char textTempTitle[3][30];
-
// ------------------------------------------------------------
int setDisplayTemp()
- { int numTemp=0;
- for (numTemp=1;numTemp<3;numTemp=numTemp+1)
- {
- BSP_LCD_SetFont(&Font16);
+ { int numTemp=0;
+ for (numTemp=1;numTemp<3;numTemp=numTemp+1)
+ { BSP_LCD_SetFont(&Font16);
BSP_LCD_SetBackColor(backColorTempTitle[numTemp]);
BSP_LCD_SetTextColor(backColorTempTitle[numTemp]);
BSP_LCD_FillRect(xTempTitle[numTemp], yTempTitle[numTemp], dxTempTitle[numTemp], dyTempTitle[numTemp]);
@@ -99,25 +101,14 @@
dxTempTitle[1]=200;dyTempTitle[1]=23;
xTxtTempTitle[1]=15;yTxtTempTitle[1]=34;
backColorTempTitle[1]=LCD_COLOR_BLACK;txtColorTempTitle[1]=LCD_COLOR_GREEN;
- sprintf(textTempTitle[1]," temp Salon ");
+ //sprintf(textTempTitle[1]," temp Salon ");
xTempTitle[2]=264;yTempTitle[2]=30;dxTempTitle[2]=200;dyTempTitle[2]=23;xTxtTempTitle[2]=265;yTxtTempTitle[2]=34;
backColorTempTitle[2]=LCD_COLOR_BLACK;txtColorTempTitle[2]=LCD_COLOR_GREEN;
- sprintf(textTempTitle[2]," temp Ext ");
+ // sprintf(textTempTitle[2]," temp Ext ");
int xx=setDisplayTemp();
return 1;
}
-// GroveStreams Settings
-extern const char gsApiKey[] = "YOUR_SECRET_API_KEY_HERE"; //Change This!!!
-extern const char gsCompName[] = "STM32F746+Discovery"; //Optionally change. Set this to give your component a name when it initially registers. Encode special chars such as spaces.
-
-extern const char gsCompTmplId[]= ""; //Optional. Tells GS what template to use when the feed initially arrives and a new component needs to be created.
-
-////GroveStreams groveStreams(gsApiKey, &lcd);
-extern GroveStreams groveStreams;
-
-extern const char* myMac;
-int displayOn = 0;
// ------------------------------------------------------------
int initDatasGuiJPA()
{ ////lcd.clear();
@@ -135,8 +126,7 @@
//Sending Samples (and returning current command stream values)
int sendResult=1;
printf("InitDataGuiJPA - Ethernet actif %i \n", ethernet_actif);
-
-
+
if (ethernet_actif == 0) // ethernet inactif -------------------------------------
{ // on n'utilise pas ethernet. lecture valeurs from sdcard
printf("Use local graphic datas\n");
@@ -161,12 +151,11 @@
if ((displayOn & 0x02) > 0) {touchButtonJPA1(1);}
if ((displayOn & 0x04) > 0) {touchButtonJPA1(2);}
if ((displayOn & 0x08) > 0) {touchButtonJPA1(3);}
- if ((displayOn & 0x10) > 0) {touchButtonJPA1(4);}
-
+ if ((displayOn & 0x10) > 0) {touchButtonJPA1(4);}
}
else
{
- sendResult = groveStreams.sendInitDatasJPA(myMac, samples, gsCompName, gsCompTmplId, resultBuffer, sizeof resultBuffer);
+ /////////// sendResult = groveStreams.sendInitDatasJPA(myMac, samples, gsCompName, gsCompTmplId, resultBuffer, sizeof resultBuffer);
if (sendResult == 0)
{ ////lcd.printf("Send Successful");
printf("Send Successful\n");
@@ -289,8 +278,7 @@
}
} // fin test send result
} // fin test ethernet actif
- if ((displayOn & 0x01) > 0) {setDisplayTemp();}
-
+ if ((displayOn & 0x01) > 0) {setDisplayTemp();}
return 1;
}
--- a/ManageBufferJPA.cpp Wed Dec 30 17:22:27 2020 +0000
+++ b/ManageBufferJPA.cpp Wed Jan 13 19:52:35 2021 +0000
@@ -1,7 +1,6 @@
#include "mbed.h"
const int kMaxBufferSize = 125;
-
volatile char bufferSerialUSB[kMaxBufferSize+3];
volatile int idxSerialIntUSB = 0;
int idxSerialUserUSB = 0;
@@ -9,7 +8,6 @@
char stringSerialUSB[kMaxBufferSize+3];
int stringSerialUSBok = 0; // si ==1 alors trame dispo (fin de trame == LF ou 10
int idxSerialStringUSB = 0;
-
volatile char bufferSerial2[kMaxBufferSize+3];
volatile int idxSerialInt2 = 0;
int idxSerialUser2 = 0;
@@ -17,7 +15,6 @@
char stringSerial2[kMaxBufferSize+3];
int stringSerial2ok = 0; // si ==1 alors trame dispo (fin de trame == LF ou 10
int idxSerialString2 = 0;
-
volatile char bufferSerial7[kMaxBufferSize+3];
volatile int idxSerialInt7 = 0;
int idxSerialUser7 = 0;
@@ -32,10 +29,8 @@
RawSerial serial7(PF_7, PF_6); // TX, RX for extension
// ---------------------------------------------------
void serialUSB_int_recv()
- {
- if(serialUSB.readable())
- {
- bufferSerialUSB[idxSerialIntUSB]=(serialUSB.getc());
+ { if(serialUSB.readable())
+ { bufferSerialUSB[idxSerialIntUSB]=(serialUSB.getc());
idxSerialIntUSB++;
if (idxSerialIntUSB >= kMaxBufferSize) {idxSerialIntUSB = 0;}
bufferSerialUSB[idxSerialIntUSB]= 0;
@@ -45,10 +40,8 @@
}
// ---------------------------------------------------------------------------
void serial2_int_recv()
- {
- if(serial2.readable())
- {
- bufferSerial2[idxSerialInt2]=(serial2.getc());
+ { if(serial2.readable())
+ { bufferSerial2[idxSerialInt2]=(serial2.getc());
idxSerialInt2++;
if (idxSerialInt2 >= kMaxBufferSize) {idxSerialInt2 = 0;}
bufferSerial2[idxSerialInt2]= 0;
@@ -58,10 +51,8 @@
}
// ----------------------------------------------------------------------------
void serial7_int_recv()
- {
- if(serial7.readable())
- {
- bufferSerial7[idxSerialInt7]=(serial7.getc());
+ { if(serial7.readable())
+ { bufferSerial7[idxSerialInt7]=(serial7.getc());
//printf("%c",bufferSerial7[idxSerialInt7]);
idxSerialInt7++;
if (idxSerialInt7 >= kMaxBufferSize) {idxSerialInt7 = 0;}
@@ -72,8 +63,7 @@
}
// --------------------------------------------------------------------------------
void initSerial()
- {
- serialUSB.baud(115200);
+ { serialUSB.baud(115200);
serialUSB.attach(&serialUSB_int_recv, Serial::RxIrq);
serial2.baud(115200); // required for Tasmota
//serial2.baud(57600); // required for UDP bridge
@@ -86,22 +76,17 @@
}
// ---------------------------------------------------------------------------
void sendSerialUSB(char * str)
- {
- serialUSB.printf(str);
+ { serialUSB.printf(str);
}
// ---------------------------------------------------------------------------
void receiveSerialUSB()
- {
- char x;
+ { char x;
if (stringSerialUSBok == 0) // string user dispo flag a mettre a 0 par user a chaque lecture de string
- {
- while(idxSerialIntUSB != idxSerialUserUSB)
- {
- x=bufferSerialUSB[idxSerialUserUSB];
+ { while(idxSerialIntUSB != idxSerialUserUSB)
+ { x=bufferSerialUSB[idxSerialUserUSB];
//printf("%c",x);
idxSerialUserUSB = idxSerialUserUSB + 1;
- if (idxSerialUserUSB >= kMaxBufferSize) {idxSerialUserUSB = 0;}
-
+ if (idxSerialUserUSB >= kMaxBufferSize) {idxSerialUserUSB = 0;}
stringSerialUSB[idxSerialStringUSB] = x;
idxSerialStringUSB = idxSerialStringUSB + 1;stringSerialUSB[idxSerialStringUSB] = 0;
if (idxSerialStringUSB >= kMaxBufferSize)
@@ -113,22 +98,17 @@
}
// ------------------------------------------------------------------------------
void sendSerial2(char * str)
- {
- serial2.printf(str);
- }
+ { serial2.printf(str);
+ }
// ------------------------------------------------------------------------------
void receiveSerial2()
- {
- char x;
- if (stringSerial2ok == 0) // string user dispo flag a mettre a 0 par user a chaque lecture de string
- {
- while(idxSerialInt2 != idxSerialUser2)
- {
- x=bufferSerial2[idxSerialUser2];
+ {char x;
+ if (stringSerial2ok == 0) // string user dispo flag a mettre a 0 par user a chaque lecture de string
+ { while(idxSerialInt2 != idxSerialUser2)
+ { x=bufferSerial2[idxSerialUser2];
//printf("%c",x);
idxSerialUser2 = idxSerialUser2 + 1;
- if (idxSerialUser2 >= kMaxBufferSize) {idxSerialUser2 = 0;}
-
+ if (idxSerialUser2 >= kMaxBufferSize) {idxSerialUser2 = 0;}
stringSerial2[idxSerialString2] = x;
idxSerialString2 = idxSerialString2 + 1;stringSerial2[idxSerialString2] = 0;
if (idxSerialString2 >= kMaxBufferSize)
@@ -140,18 +120,14 @@
}
// --------------------------------------------------------------------------------
void sendSerial7(char * str)
- {
- serial7.printf(str);
+ { serial7.printf(str);
}
// -------------------------------------------------------------------------------
void receiveSerial7()
- {
- char x;
+ { char x;
if (stringSerial7 == 0) // string user dispo flag a mettre a 0 par user a chaque lecture de string
- {
- while(idxSerialInt7 != idxSerialUser7)
- {
- x=bufferSerial7[idxSerialUser7];
+ { while(idxSerialInt7 != idxSerialUser7)
+ { x=bufferSerial7[idxSerialUser7];
//printf("%c",x);
idxSerialUser7 = idxSerialUser7 + 1;
if (idxSerialUser7 >= kMaxBufferSize) {idxSerialUser7 = 0;}
--- a/SDFileSystem_Warning_Fixed.lib Wed Dec 30 17:22:27 2020 +0000 +++ b/SDFileSystem_Warning_Fixed.lib Wed Jan 13 19:52:35 2021 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/38domo/code/SDFileSystem_Warning_Fixed/#869ccd13fa0a +https://os.mbed.com/users/38domo/code/SDFileSystem_Warning_Fixed/#75d0098c7522
--- a/main.cpp Wed Dec 30 17:22:27 2020 +0000
+++ b/main.cpp Wed Jan 13 19:52:35 2021 +0000
@@ -1,5 +1,6 @@
/* --------------------------------------------------------------------------
-
+// update 01/01/2021: remove ethernet calls : ok
+//
// update 30/12 update libs
//
// test compile ok 31/07/2020
@@ -57,12 +58,9 @@
// need to add CAN and WiFi
STM32F746 GroveStreams Stream Feed via Ethernet
-
This GroveStreams example is designed for the STM32F746.
https://www.grovestreams.com/developers/getting_started_stm32F746.html
-
The STM32 uses DHCP and DNS for a simpler network setup.
-
*/
#if !FEATURE_LWIP
@@ -71,13 +69,12 @@
#include "mbed.h"
#include "LcdDiscoF746NgTracer.h"
-#include "GroveStreams.h"
+// #include "GroveStreams.h"
#include "MbedJSONValue.h"
#include "stm32746g_discovery_lcd.h"
#include "stm32746g_discovery_ts.h"
#include "CANMsg.h"
//#include "ManageBufferJPA.h"
-
#include "main.h"
extern char textButton[5][8];
@@ -100,6 +97,7 @@
int setTemp1(std::string temp1);
int setTemp2(std::string temp2);
int sendInitDatasJPA(int xx);
+int timer_lcd_on = 0;
//#SDCARD
int mainSDCardJPA(); //in sdcardjpa.cpp in lib /sdfilesystem_warning_fixedd
@@ -157,6 +155,7 @@
float voltage;
Timer timer;
+extern Timer timer_lcd;
AnalogIn analogIn(A0);
// CAN ------------------------------------------------------------
@@ -240,11 +239,11 @@
{ initSerial();
// attach ISR to handle received messages
timer.start(); // start timer
- sendSerialUSB("CAN_Hello board serialUSB #1\r\n");
-
+ timer_lcd.start(); // start timer lcd off
+ timer_lcd_on = 1;
+ sendSerialUSB("CAN_Hello board serialUSB #1\r\n");
sendSerial2("CAN_Hello board serial2 #1\r\n");
sendSerial7("CAN_Hello board serial7 #1\r\n");
-
printf("\nInit SDCard ...\n");
mainSDCardJPA() ; // init SD - read prog parameters from SD (from sdcardjpa.cpp in sdfilesystem_warning_fixed lib
// reaf following datas
@@ -280,7 +279,7 @@
////lcd.printf("Starting...");
printf("Starting...\n");
lastToucheTime = time(NULL);
- char data[5];
+ char data[5];
// config can --------------------------------------
can.frequency(125000); // set CAN bit rate to 125 kbps
@@ -296,7 +295,7 @@
// main loop ---------------------------------------------------
while (true) {
- if (CanRcv > 0)
+ if (CanRcv > 0) // message CAN received ---------------------
{ CanRcv = 0;
printMsg(rxMsg,1);
BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"Can msg rec", CENTER_MODE);
@@ -307,10 +306,10 @@
//serialUSB.printf(" voltage = %e V\r\n", voltage);
}
}
- if (msgSerialUSB > 0) {receiveSerialUSB();}
+ if (msgSerialUSB > 0) {receiveSerialUSB();} // serial USB message received ----------------
if (stringSerialUSBok == 1) {printf("Trame SerialUSB : %s",stringSerialUSB);stringSerialUSBok=0;}
- if (msgSerial2 > 0) {receiveSerial2();}
+ if (msgSerial2 > 0) {receiveSerial2();} // serial bridge message received -----------------
if (stringSerial2ok == 1)
{ printf("Trame Serial2 : %s",stringSerial2);
stringSerial2ok=0;
@@ -324,16 +323,16 @@
parse(mbedJson, stringSerial2);
sprintf((char*)text, "HTTP string : %s\n", stringSerial2);
if (mbedJson.hasMember("Temp1"))
- { printf("Serial2 temp1: %s",stringSerial2);
+ { printf("Serial2 temp1: %s",stringSerial2);
int pp = setTemp1(mbedJson["Temp1"].get<std::string>()); // display temp1 on lcd
}
if (mbedJson.hasMember("Temp2"))
- { int tt=setTemp2(mbedJson["Temp2"].get<std::string>());
+ { int tt=setTemp2(mbedJson["Temp2"].get<std::string>());
}
// add buttons parameters
// decode button trame
if (mbedJson.hasMember("Touche4"))
- { printf("Touche 4 update status received");
+ { printf("Touche 4 update status received");
string s;
s = mbedJson["Touche4"]["Status"].get<std::string>();
sprintf(statusButton[4],s.c_str());
@@ -350,7 +349,7 @@
touchButtonJPA1(4);
}
if (mbedJson.hasMember("Touche1"))
- { printf("Touche 1 update status received");
+ { printf("Touche 1 update status received");
string s;
s = mbedJson["Touche1"]["Status"].get<std::string>();
sprintf(statusButton[1],s.c_str());
@@ -384,7 +383,7 @@
touchButtonJPA1(2);
}
if (mbedJson.hasMember("Touche3"))
- { printf("Touche 3 update status received");
+ { printf("Touche 3 update status received");
string s;
s = mbedJson["Touche3"]["Status"].get<std::string>();
sprintf(statusButton[3],s.c_str());
@@ -401,11 +400,18 @@
touchButtonJPA1(3);
}
}
- }
- if (msgSerial7 > 0) {receiveSerial7();}
+ } // end serial bridge message received -----------
+ if (msgSerial7 > 0) {receiveSerial7();}// serial7 message received - not working ---------------
if (stringSerial7ok == 1) {printf("Trame Serial7 : %s",stringSerial7);stringSerial7ok=0;}
- // timer send can
+ // timer lcd --------------------
+ if(timer_lcd.read() >= 1000) // check for timeout
+ { timer_lcd.stop(); // stop the timer
+ timer_lcd.reset(); // reset the timer
+ timer_lcd_on =0;
+ BSP_LCD_DisplayOff();
+ }
+ // timer send can ------------------------
if(timer.read_ms() >= 10000) // check for timeout
{ timer.stop(); // stop the timer
timer.reset(); // reset the timer
@@ -430,28 +436,32 @@
//BSP_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)"-----------", CENTER_MODE);
}
timer.start(); // insert transmission lag
- } // end if timer
- //touch screen
- int xx = touchJPA1(); //
- if (xx > 0)
- { if (xx == 4)
- { // send trame to can
- txMsg.id = 0x100130CB;//TX_ID; // set the message ID
- txMsg.format = CANExtended ; //extended
- txMsg.len=2;
- txMsg.data[0]=8;txMsg.data[1]=2; // append data (total data length must be <= 8 bytes!)
-
- if(can.write(txMsg)) // transmit message
- { printMsg(txMsg,0);
- printf("TX CAN OK \n");
- //BSP_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)"TX CAN OK", CENTER_MODE);
- //BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)"--------", CENTER_MODE);
- }
- else
- { printf("TX CAN Fail \n");
- BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)"TX CAN Fail", CENTER_MODE);
- BSP_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)"-----------", CENTER_MODE);
- }
+ } // end if timer send can -------------------
+ // touch screen detection -------------------------------
+ int xx = touchJPA1(); //
+ if (xx > 0) // touch detected
+ { if (xx==9) // display pressed but not a touch
+ { timer_lcd.stop(); // stop the timer
+ timer_lcd.reset(); // reset the timer
+ /////////BSP_LCD_DisplayOn();
+ }
+ if (xx == 4) // touch 4 pressed
+ { // send trame to can
+ txMsg.id = 0x100130CB;//TX_ID; // set the message ID
+ txMsg.format = CANExtended ; //extended
+ txMsg.len=2;
+ txMsg.data[0]=8;txMsg.data[1]=2; // append data (total data length must be <= 8 bytes!)
+ if(can.write(txMsg)) // transmit message
+ { printMsg(txMsg,0);
+ printf("TX CAN OK \n");
+ //BSP_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)"TX CAN OK", CENTER_MODE);
+ //BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)"--------", CENTER_MODE);
+ }
+ else
+ { printf("TX CAN Fail \n");
+ BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)"TX CAN Fail", CENTER_MODE);
+ BSP_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)"-----------", CENTER_MODE);
+ }
}
xx = sendTouchJPA(xx);
lastToucheTime = time(NULL);
@@ -478,8 +488,8 @@
char resultBuffer[700]= {0};
//Sending Samples (and returning current command stream values)
time_t connectAttemptTime = time(NULL);
- int sendResult = groveStreams.send(myMac, samples, gsCompName, gsCompTmplId, resultBuffer, sizeof resultBuffer); //receive mqtt
-
+///////// int sendResult = groveStreams.send(myMac, samples, gsCompName, gsCompTmplId, resultBuffer, sizeof resultBuffer); //receive mqtt
+ int sendResult = 0;
if (sendResult == 0) {
////lcd.printf("Send Successful");
printf("Send Successful\n");
--- a/main.h Wed Dec 30 17:22:27 2020 +0000
+++ b/main.h Wed Jan 13 19:52:35 2021 +0000
@@ -2,27 +2,19 @@
#define __MAIN_H
#ifdef __cplusplus
- extern "C" {
+ extern "C" {
+ #endif
+ ///#include "GroveStreams.h"
+ #include "mbed.h"
+ // GroveStreams Settings
+ const char gsApiKey[] = "YOUR_SECRET_API_KEY_HERE"; //Change This!!!
+ const char gsCompName[] = "STM32F746+Discovery"; //Optionally change. Set this to give your component a name when it initially registers. Encode special chars such as spaces.
+ const char gsCompTmplId[] = ""; //Optional. Tells GS what template to use when the feed initially arrives and a new component needs to be created.
+ ////GroveStreams groveStreams(gsApiKey, &lcd);
+ /////////GroveStreams groveStreams(gsApiKey);
+ ///////////////////////////////const char* myMac = groveStreams.getMACAddress();
+ time_t seconds = time(NULL);
+ #ifdef __cplusplus
+ }
+ #endif
#endif
-
-#include "GroveStreams.h"
-#include "mbed.h"
-
-// GroveStreams Settings
-const char gsApiKey[] = "YOUR_SECRET_API_KEY_HERE"; //Change This!!!
-const char gsCompName[] = "STM32F746+Discovery"; //Optionally change. Set this to give your component a name when it initially registers. Encode special chars such as spaces.
-
-const char gsCompTmplId[] = ""; //Optional. Tells GS what template to use when the feed initially arrives and a new component needs to be created.
-
-////GroveStreams groveStreams(gsApiKey, &lcd);
-GroveStreams groveStreams(gsApiKey);
-
-const char* myMac = groveStreams.getMACAddress();
-
-time_t seconds = time(NULL);
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif
--- a/touchScreenJPA.cpp Wed Dec 30 17:22:27 2020 +0000
+++ b/touchScreenJPA.cpp Wed Jan 13 19:52:35 2021 +0000
@@ -2,26 +2,22 @@
#include "stm32746g_discovery_lcd.h"
#include "stm32746g_discovery_ts.h"
#include "mbed.h"
-#include "GroveStreams.h"
+//#include "GroveStreams.h"
#include "MbedJSONValue.h"
Timer timer_touch[16];
+Timer timer_lcd;
void sendSerial2(char * str);
void sendSerial7(char * str);
int initDisplayTemp();
-
// GroveStreams Settings
//extern const char gsApiKey[];// = "YOUR_SECRET_API_KEY_HERE"; //Change This!!!
extern const char gsCompName[];// = "STM32F746+Discovery"; //Optionally change. Set this to give your component a name when it initially registers. Encode special chars such as spaces.
-
extern const char gsCompTmplId[]; //Optional. Tells GS what template to use when the feed initially arrives and a new component needs to be created.
-
////GroveStreams groveStreams(gsApiKey, &lcd);
-extern GroveStreams groveStreams;
-
+//extern GroveStreams groveStreams;
extern const char* myMac;
-
extern time_t seconds;
time_t seconds_touches = 0;
extern time_t lastToucheTime;
@@ -46,8 +42,7 @@
BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT FAIL", CENTER_MODE);
}
else
- {
- BSP_LCD_Clear(LCD_COLOR_DARKBLUE);
+ { BSP_LCD_Clear(LCD_COLOR_DARKBLUE);
BSP_LCD_SetBackColor(LCD_COLOR_BLACK);
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
//BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT OK", CENTER_MODE);
@@ -69,10 +64,8 @@
// -----------------------------------------------------------------------------------------
int touchButtonJPA1(int numButton)
- {
- if ((numButton > 0) && (numButton < 5))
- {
- BSP_LCD_SetBackColor(backColorButton[numButton]);
+ { if ((numButton > 0) && (numButton < 5))
+ { BSP_LCD_SetBackColor(backColorButton[numButton]);
BSP_LCD_SetTextColor(backColorButton[numButton]);
BSP_LCD_FillRect(xButton[numButton], yButton[numButton], dxButton[numButton], dyButton[numButton]);
BSP_LCD_SetTextColor(txtColorButton[numButton]);
@@ -128,16 +121,14 @@
// --------------------------------------------------------------------------
int touchJPA1()
- {
- //touch screen
+ { //touch screen
TS_StateTypeDef TS_State;
uint16_t x, y;
uint8_t text[30];
uint8_t status = 0;
uint8_t idx;
static uint8_t cleared = 0;
- uint8_t prev_nb_touches = 0;
-
+ uint8_t prev_nb_touches = 0;
int tt = 0;
for (tt=0;tt<16;tt++)
{if(timer_touch[tt].read_ms() > 200)
@@ -151,25 +142,20 @@
//BSP_LCD_ClearStringLine(idx);
}
}
- prev_nb_touches = TS_State.touchDetected;
-
+ prev_nb_touches = TS_State.touchDetected;
cleared = 0;
-
//sprintf((char*)text, "Touches: %d", TS_State.touchDetected);
//BSP_LCD_DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);
-
for (idx = 0; idx < TS_State.touchDetected; idx++) {
x = TS_State.touchX[idx];
y = TS_State.touchY[idx];
//sprintf((char*)text, "Touch %d: x=%d y=%d ", idx+1, x, y);
//BSP_LCD_DisplayStringAt(0, LINE(idx+1), (uint8_t *)&text, LEFT_MODE);
}
-
- //BSP_LCD_DrawPixel(TS_State.touchX[0], TS_State.touchY[0], LCD_COLOR_ORANGE);
+ //BSP_LCD_DrawPixel(TS_State.touchX[0], TS_State.touchY[0], LCD_COLOR_ORANGE);
if ((TS_State.touchY[0] > 160) && (TS_State.touchY[0] < (160+80)))
- {
- int numTouche = 0;
+ { int numTouche = 0;
if ((TS_State.touchX[0] > 10) && (TS_State.touchX[0] < (10+100)))
{if(timer_touch[0].read_ms() == 0) {numTouche = 1;timer_touch[0].start();}}
if ((TS_State.touchX[0] > 130) && (TS_State.touchX[0] < (130+100)))
@@ -179,14 +165,23 @@
if ((TS_State.touchX[0] > 370) && (TS_State.touchX[0] < (370+100)))
{if(timer_touch[3].read_ms() == 0) {numTouche = 4;timer_touch[3].start();}}
if (numTouche >0)
- {
- printf("Touche : %d", numTouche);
+ { printf("Touche : %d", numTouche);
sprintf((char*)text, "Touche : %d", numTouche);
//BSP_LCD_DisplayStringAt(200,0, (uint8_t *)&text, LEFT_MODE);
status = numTouche;
}
- else {lastToucheTime = 0;}
+ else
+ {lastToucheTime = 0;
+ }
}
+ else
+ {
+ int numTouche = 9;
+ printf("Touche : %d", numTouche);
+ timer_lcd.stop(); // stop the timer
+ timer_lcd.reset(); // reset the timer
+ BSP_LCD_DisplayOn();
+ }
} else {
lastToucheTime = 0;
if (!cleared) {
@@ -213,7 +208,8 @@
// modifier pour rajouter test ethernet / wifi et action en fonction
if (ethernet_actif == 1 ) // ethernet actif
{ printf("\ntraitement Ethernet\n",xx);
- int sendResult = groveStreams.sendJPA(myMac, samples, gsCompName, gsCompTmplId, resultBuffer, sizeof resultBuffer);
+///////////// int sendResult = groveStreams.sendJPA(myMac, samples, gsCompName, gsCompTmplId, resultBuffer, sizeof resultBuffer);
+ int sendResult = 0;
if (sendResult == 0)
{ ////lcd.printf("Send Successful");
printf("Send Successful\n");