43 lines
1023 B
C++
Executable File
43 lines
1023 B
C++
Executable File
|
|
#include "cameteo_teensy.h"
|
|
|
|
void stopRPI() {
|
|
//Stop the Raspberry Pi via the MOSFET (grid connected to the RPI_PWR_PIN)
|
|
|
|
pinMode(RPI_PWR_PIN, INPUT); //Eteint via le MOSFET
|
|
rpi_status = false;
|
|
}
|
|
|
|
bool isStartedPI() {
|
|
//Return true if the R-Pi respond to an simple request
|
|
return rpi_status;
|
|
}
|
|
|
|
void startRPI() {
|
|
//Start the Raspberry Pi via the MOSFET (grid connected to the RPI_PWR_PIN)
|
|
if (!isStartedPI()) {
|
|
pinMode(RPI_PWR_PIN, OUTPUT);
|
|
digitalWrite(RPI_PWR_PIN, LOW);
|
|
rpi_status = true;
|
|
}
|
|
}
|
|
|
|
void sendDataToSerial(String data) {
|
|
if (isStartedPI()) {
|
|
char c[100]; // char buffer for conversion String->char
|
|
data.toCharArray(c, sizeof(data)); //convert data string to char array
|
|
|
|
// //start serial comm. if needed
|
|
// if(!SERIAL_PORT) {
|
|
// SERIAL_PORT.begin(SERIAL_BAUD_RATE);
|
|
// //while(!SERIAL_PORT);
|
|
// }
|
|
|
|
SERIAL_PORT.print(c); // send data on serial port
|
|
|
|
}
|
|
else {
|
|
//error RPI is not started
|
|
}
|
|
}
|