re bonjour,
voici mon code, comme demandé:
"
#include <ESP8266WiFi.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
const char* ssid = "";
const char* password = "";
const char* host = "192.168.1.15";
const char* streamId = "....................";
const char* privateKey = "....................";
byte buffer[1024];
byte convertedValues[1024];
// If using software SPI (the default case):
#define OLED_MOSI D4
#define OLED_CLK D3
#define OLED_DC D2
#define OLED_CS D1
#define OLED_RESET D0
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
static const unsigned char PROGMEM logo16_glcd_bmp[] =
{ B00000000, B11000000,
B00000001, B11000000,
B00000001, B11000000,
B00000011, B11100000,
B11110011, B11100000,
B11111110, B11111000,
B01111110, B11111111,
B00110011, B10011111,
B00011111, B11111100,
B00001101, B01110000,
B00011011, B10100000,
B00111111, B11100000,
B00111111, B11110000,
B01111100, B11110000,
B01110000, B01110000,
B00000000, B00110000 };
#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
void setup() {
Serial.begin(115200);
delay(10);
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC);
// init done
// Show image buffer on the display hardware.
// Since the buffer is intialized with an Adafruit splashscreen
// internally, this will display the splashscreen.
display.display();
delay(2000);
// Clear the buffer.
display.clearDisplay();
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
delay(5000);
Serial.print("connecting to ");
Serial.println(host);
// Use WiFiClient class to create TCP connections
WiFiClient client;
const int httpPort = 50585;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}
// This will send the request to the server
// client.print("Send this data to server");
String line = client.readString();//ok marche
Serial.println(line);
line.getBytes(buffer,1024);
display.clearDisplay();
byte flag = atoh(convertedValues,buffer);
if (flag != NULL)
{
Serial.println("convertedValues");
for (int i = 0; i < sizeof(buffer); i++)
{
Serial.print(convertedValues, HEX);//vérification de l'image*
}
display.drawBitmap(0, 0, convertedValues, 128, 64, 1);
display.display();//affiche l'image sur le display
}
- Serial.println("2: wait 5 sec...");*
- delay(5000);*
}
byte *atoh(byte *destination, byte *source)
{
byte *ret = destination;
for(int lsb, msb; *source; source += 2)
{
msb = tolower(*(source));
lsb = tolower(*(source +1));
msb -= isdigit(msb) ? 0x30 : 0x57;
lsb -= isdigit(lsb) ? 0x30 : 0x57;
if((msb < 0x0 || msb > 0xf) || (lsb < 0x0 || lsb > 0xf))
{
*ret = 0;
return NULL;
}
if(msb==0x0){
source -=1;
*destination++ = (uint8_t)0;
}
else{
*destination++ = (uint8_t)(lsb | (msb << 4));
}
}
*destination = 0;
return ret;
}
"
je ne sais pas si j'ai bien procédé pour afficher le code?
Si vous trouvez le bug, merci de l'explication.
Fred123