Bonjour tous,
Je me permet vous demander de l'aide, je suis en train de me casser les dents sur un projet de testeur DHCP pour m'aider dans mon travail de tous les jours,
Je suis gestionnaire réseau, et dans mon métier il est très fréquent de devoir vérifier que les serveurs DHCP et les configuration des portes réseau sont bien configuré. Un PC portable pourrais bien faire le travail, mais je cherche à réaliser un petit boitier ( v2.0 ) pour venir en aide aux opérateurs des différents site de production.
Jusqu’à ce jour, j'utilise la v1 de ce petit gadget donc le code ci-joint sans rencontre de problème. Suite à une nouvelle modification de réseau et au passage en Dot1X, j'aurais besoin avec un seul boitier de pouvoir régler plusieurs mac adresse, raisons pour laquelle je suis sur une version v2.0.
J'ai donc revu le code, mais j'ai de gros problème de mémoire lorsque j'ajoute la fonction ether.dhcpSetup. L'arduino se met à rebouter sans arrêt. reboot.
Voici donc le code V1 qui fonctionne correctement et le code V2, incomplet qui reboot....
Pourriez-vous m'aider dans ma réalisation ??
Merci d'avance
Code V1
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <EtherCard.h>
static const unsigned char PROGMEM logo_bmp[] =
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x07,0x00,0x00,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xfe,0x00,0x00,0x0f,0x00,0x01,0xff,0xff,0xfe,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xff,0x00,0x00,0x0f,0x80,0x01,0xff,0xff,0xfe,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xff,0x80,0x00,0x0f,0x00,0x03,0xff,0xff,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x3f,0x80,0x00,0x07,0x00,0x07,0xff,0xff,0xf8,0x00,0x00,0x00,0x1e,0x00,
0x00,0x07,0x0f,0x80,0x00,0x00,0x00,0x06,0x00,0x7f,0xf0,0x00,0x00,0x00,0x3e,0x00,0x00,0x07,0x03,0x87,0x18,0x01,0x00,0x00,0x00,0x07,0x80,0x7e,0x07,0xf8,0x3f,0x80,
0x00,0x07,0x01,0x9f,0xfe,0x07,0x80,0x00,0x00,0x0f,0x00,0xff,0x0f,0xf8,0x3f,0x80,0x00,0x0f,0x00,0x0f,0xfe,0x3f,0x80,0x00,0x00,0x0e,0x03,0xff,0x9e,0x78,0x3f,0x80,
0x00,0x0f,0x80,0x0f,0xff,0x3f,0x80,0x00,0x00,0x1c,0x03,0xef,0xbf,0x00,0x3e,0x00,0x00,0x0f,0xc0,0x0f,0x9f,0x0f,0x80,0x00,0x00,0x3c,0x03,0xe7,0x3f,0xfc,0x3e,0x00,
0x00,0x0f,0xf8,0x0f,0x9f,0x0f,0x80,0x00,0x00,0x38,0x03,0xe7,0x3f,0xfe,0x3c,0x00,0x00,0x1f,0xf0,0x0f,0x9e,0x0f,0x80,0x00,0x00,0x70,0x03,0xfe,0x1f,0xfe,0x3e,0x00,
0x00,0x39,0xf0,0x0f,0xde,0x0f,0x80,0x00,0x00,0xe0,0x03,0xf0,0x0f,0xfc,0x3e,0x00,0x00,0x70,0x00,0x0f,0xfe,0x0f,0x80,0x00,0x00,0xe0,0x01,0xfe,0x00,0x3c,0x3f,0x00,
0x00,0xf0,0x00,0x0f,0xfc,0x0f,0x80,0x00,0x01,0xc0,0x01,0xfe,0x1f,0xf8,0x3f,0x00,0x00,0xf0,0x00,0x0f,0xf8,0x0f,0x80,0x00,0x03,0x80,0x00,0xf8,0x0f,0xe0,0x1f,0x00,
0x01,0xf0,0x00,0x0f,0x80,0x0f,0x00,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x01,0xf8,0x00,0xef,0x80,0x00,0x00,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0xfe,0x03,0xcf,0x80,0x00,0x00,0x01,0xee,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xcf,0x00,0x00,0x00,0x01,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xff,0xff,0x8f,0x00,0x00,0x00,0x03,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3f,0xff,0x8f,0x00,0x00,0x00,0x01,0xf0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x0f,0xfc,0x0f,0x00,0x00,0x00,0x00,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
#define OLED_RESET 4
#define LOGO_HEIGHT 64
#define LOGO_WIDTH 128
Adafruit_SSD1306 display(OLED_RESET);
static byte mymac[] = { 0x00,0x00,0x00,0x1,0x01,0x01 };
byte Ethernet::buffer[500];
unsigned long temps_start;
unsigned long temps_proccess;
byte erreur = true;
byte pas = 1;
bool bouton = true;
void setup() {
pinMode(3, INPUT_PULLUP);
Serial.begin(9600);
Serial.println("Start");
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
erreur =false;
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)
// 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.clearDisplay();
display.drawBitmap(
(display.width() - LOGO_WIDTH ) / 2,
(display.height() - LOGO_HEIGHT) / 2,
logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);
display.display();
delay(2000);
}
void loop() {
if (erreur){
switch (pas) {
case 1:
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println(F(" Setting up DHCP"));
display.println();
display.print(" ");
for (int i=0; i<=5 ;i++){
if (mymac[i] < 10) display.print("0");
display.print(mymac[i]);
if (i < 5) display.print(":");
}
display.display();
delay(1000);
temps_start = millis();
Serial.println(ether.dhcpSetup());
if (!ether.dhcpSetup()){
pas = 0;
}else{
temps_proccess=millis()-temps_start;
pas = 2;
}
// lecture IP
break;
case 2:
// affichage IP
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.print("IP : ");
display.print(ether.myip[0]);
display.print(".");
display.print(ether.myip[1]);
display.print(".");
display.print(ether.myip[2]);
display.print(".");
display.println(ether.myip[3]);
display.print("Mask: ");
display.print(ether.netmask[0]);
display.print(".");
display.print(ether.netmask[1]);
display.print(".");
display.print(ether.netmask[2]);
display.print(".");
display.println(ether.netmask[3]);
display.print("GW : ");
display.print(ether.gwip[0]);
display.print(".");
display.print(ether.gwip[1]);
display.print(".");
display.print(ether.gwip[2]);
display.print(".");
display.println(ether.gwip[3]);
display.print("DNS : ");
display.print(ether.dnsip[0]);
display.print(".");
display.print(ether.dnsip[1]);
display.print(".");
display.print(ether.dnsip[2]);
display.print(".");
display.println(ether.dnsip[3]);
display.display();
break;
case 3:
// Temps
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println(" Temps requette");
display.println("");
display.print(" ");
display.print(temps_proccess);
display.print(" Mils");
display.display();
break;
case 0:
// pas d'adresse
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println();
display.println(F(" Pas recu d'adresse"));
display.display();
}
// test bouton
if (!digitalRead(3)&& bouton) {
pas ++;
if (pas >3)
pas = 1;
bouton = false;
delay(30);
}
if( digitalRead(3)) bouton = true;
Serial.print(pas);
Serial.print("==>");
Serial.print(bouton);
Serial.print("==>");
Serial.println(digitalRead(3));
} else {
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,0);
display.println("Erreur avec le controleur");
display.println("");
display.println(" Ethernet");
display.display();
delay(2000);
display.clearDisplay();
}
}
et pour la version 2
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <EtherCard.h>
#include <EEPROM.h>
#include "Variables.h"
#define pinButton 4
#define OLED_RESET 4
#define LOGO_HEIGHT 64
#define LOGO_WIDTH 128
#define JaugePosition 100
#define JaugeNombre 3
#define TensionOffset 650
byte Ethernet::buffer[500];
String MainMenu[] = {"","","","","","",""};
byte mymac[6];
byte KrMac[5][6] = { { 0x01,0x01,0x01,0x00,0x00,0x01 },
{ 0x02,0x02,0x02,0x00,0x00,0x01 },
{ 0x03,0x03,0x03,0x00,0x00,0x01 },
{ 0x04,0x04,0x04,0x00,0x00,0x01 },
{ 0x05,0x05,0x05,0x00,0x00,0x01 }};
bool ChangeMac = false;
byte pas = 1;
int Tension = 1000;
unsigned long temps_start;
unsigned long temps_proccess;
bool bouton = false;
byte pos = 1;
unsigned long dernierTempsBouton = 0;
unsigned long rebondDelay = 50;
bool pinStatus = false;
bool oldEtatBouton = false;
bool changeBouton = false;
bool first = true;
const unsigned char PROGMEM logo_bmp[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0f, 0xf8, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1f, 0xfc, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3f, 0xfe, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x3f, 0xff, 0x00, 0x00, 0x3f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7f, 0xff, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x78, 0xff, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xf8, 0x3f, 0x00, 0x20, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xf8, 0x1f, 0x7e, 0x78, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xf8, 0x06, 0xff, 0xfe, 0x7f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0xf8, 0x00, 0x7f, 0xfe, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0xfc, 0x00, 0x7f, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0xff, 0x00, 0x7f, 0x7f, 0x7f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0xff, 0xc0, 0x7f, 0x7f, 0x3f, 0x80, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0xff, 0xc0, 0x7f, 0x7f, 0x3f, 0x80, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x07, 0xff, 0xc0, 0x7f, 0x7e, 0x3f, 0x80, 0x00, 0x03, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0f, 0xbf, 0x80, 0x7f, 0x7e, 0x3f, 0x80, 0x00, 0x07, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1f, 0x0f, 0x00, 0x7f, 0xfe, 0x3f, 0x80, 0x00, 0x07, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3f, 0x00, 0x00, 0x7f, 0xfc, 0x3f, 0x80, 0x00, 0x0f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3f, 0x00, 0x00, 0x7f, 0xf8, 0x3f, 0x80, 0x00, 0x0f, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3f, 0x00, 0x00, 0x7f, 0xf0, 0x3f, 0x80, 0x00, 0x0f, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7f, 0x80, 0x01, 0xff, 0x20, 0x3f, 0x00, 0x00, 0x1f, 0x1c, 0x08, 0x00, 0x08, 0xc0, 0x00,
0x00, 0x7f, 0xc0, 0x07, 0xff, 0x00, 0x10, 0x00, 0x00, 0x1e, 0x08, 0x1f, 0xc0, 0x7f, 0xf0, 0x00,
0x00, 0x7f, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x3f, 0xf0, 0xff, 0xf8, 0x00,
0x00, 0x3f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x7f, 0xf9, 0xff, 0xfc, 0x00,
0x00, 0x3f, 0xff, 0xff, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0xff, 0xf9, 0xff, 0xfc, 0x00,
0x00, 0x1f, 0xff, 0xff, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x01, 0xff, 0xfd, 0xfd, 0xfc, 0x00,
0x00, 0x0f, 0xff, 0xfe, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x78, 0x01, 0xfb, 0xfd, 0xfd, 0xfc, 0x00,
0x00, 0x03, 0xff, 0xf8, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x78, 0x01, 0xfb, 0xfd, 0xfd, 0xfc, 0x00,
0x00, 0x00, 0x1f, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x70, 0x01, 0xfb, 0xfd, 0xfd, 0xf8, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0xff, 0xfd, 0xfd, 0xf8, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0xe0, 0x0f, 0xff, 0xfd, 0xfd, 0xf8, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0xe0, 0x3f, 0xff, 0xfd, 0xfd, 0xf8, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xe0, 0x01, 0xe0, 0x3f, 0xfd, 0xfd, 0xfd, 0xf0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf0, 0x01, 0xc0, 0x7f, 0xf9, 0xf9, 0xfd, 0xe0, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfe, 0x03, 0xc0, 0x7f, 0xf1, 0xf1, 0xf9, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xc3, 0x80, 0x7e, 0x20, 0x80, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0x80, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xc3, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);
void FoncChangeMac(){
rebond();
if(changeBouton and pinStatus){
changeBouton = false;
if (millis() - temps_proccess > 3000) {
ChangeMac = false;
EEPROM.write(1,pos-1);
__asm__ __volatile__ ("jmp 0");
} else {
pos = pos + 1;
if (pos > 5){
pos = 1;
}
}
Affiche_menu(MainMenu, pos,5,true,3);
Serial.println(pos);
}
if(changeBouton and !pinStatus){
changeBouton = false;
temps_proccess = millis();
}
}
void rebond() {
int etatBouton = digitalRead(pinButton);
if (etatBouton != oldEtatBouton){
dernierTempsBouton = millis();
}
if ((millis() - dernierTempsBouton) >= rebondDelay){
if (etatBouton != pinStatus) {
pinStatus = etatBouton;
changeBouton = true;
}
}
oldEtatBouton = etatBouton;
}
void Affiche_menu(String *Menu, int pos, int nombre,bool mode, int centre){
Jauge();
display.setCursor(0,0);
display.setTextSize(1);
display.setTextColor(1,0);
display.println(Menu[0]);
display.println("");
if (mode){
display.setTextColor(0,1);
}
for (int i = 1 ; i <= nombre ;i++){
if (centre != 0) {
for ( int sp = 1 ; sp <= centre ; sp++){
display.print(" ");
}
}
display.println(Menu[pos]);
pos++;
if (pos > nombre){pos=1;}
display.setTextColor(1,0);
}
display.display();
}
void Jauge(){
int Tension = analogRead(A0);
display.clearDisplay();
display.drawRect(JaugePosition,0,(JaugeNombre*9),8,1);
display.fillRect(JaugePosition-3,2,JaugeNombre,4,1);
for (int i=1 ; i <= JaugeNombre; i++)
{
display.fillRect(JaugePosition+(i*8)-5,2,5,4,1);
}
int valeurTension = ((JaugeNombre*9)) - ((Tension - TensionOffset )/(12)) ;
display.fillRect(JaugePosition+2,2,valeurTension,4,0);
}
String MacToString(byte *Mac ){
char hexa[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
String resultat ="";
for (int i=0; i<=5 ;i++){
resultat += hexa[( Mac[i]/16)];
resultat += hexa[( Mac[i]%16)];
if (i < 5) resultat += ":";
}
return resultat;
}
int clearscreen()
{
for (int i = 1 ; i <= 5 ;i++){
MainMenu[i]="";
}
}
void rebond() {
int etatBouton = digitalRead(pinButton);
if (etatBouton != oldEtatBouton){
dernierTempsBouton = millis();
}
if ((millis() - dernierTempsBouton) >= rebondDelay){
if (etatBouton != pinStatus) {
pinStatus = etatBouton;
changeBouton = true;
}
}
oldEtatBouton = etatBouton;
}
void Affiche_menu(String *Menu, int pos, int nombre,bool mode, int centre){
Jauge();
display.setCursor(0,0);
display.setTextSize(1);
display.setTextColor(1,0);
display.println(Menu[0]);
display.println("");
if (mode){
display.setTextColor(0,1);
}
for (int i = 1 ; i <= nombre ;i++){
if (centre != 0) {
for ( int sp = 1 ; sp <= centre ; sp++){
display.print(" ");
}
}
display.println(Menu[pos]);
pos++;
if (pos > nombre){pos=1;}
display.setTextColor(1,0);
}
display.display();
}
void Jauge(){
int Tension = analogRead(A0);
display.clearDisplay();
display.drawRect(JaugePosition,0,(JaugeNombre*9),8,1);
display.fillRect(JaugePosition-3,2,JaugeNombre,4,1);
for (int i=1 ; i <= JaugeNombre; i++)
{
display.fillRect(JaugePosition+(i*8)-5,2,5,4,1);
}
int valeurTension = ((JaugeNombre*9)) - ((Tension - TensionOffset )/(12)) ;
display.fillRect(JaugePosition+2,2,valeurTension,4,0);
}
String MacToString(byte *Mac ){
char hexa[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
String resultat ="";
for (int i=0; i<=5 ;i++){
resultat += hexa[( Mac[i]/16)];
resultat += hexa[( Mac[i]%16)];
if (i < 5) resultat += ":";
}
return resultat;
}
int clearscreen()
{
for (int i = 1 ; i <= 5 ;i++){
MainMenu[i]="";
}
}
void setup() {
// put your setup code here, to run once:
Serial.begin (9600);
Serial.println("Start");
int valeurMac = EEPROM.read(1);
for (int i=0; i<=5 ;i++){
mymac[i] = KrMac[valeurMac][i];
}
pos=valeurMac;
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3D (for the 128x64)
display.clearDisplay();
display.drawBitmap(0, 0, logo_bmp, 128, 64, WHITE); // display.drawBitmap(x position, y position, bitmap data, bitmap width, bitmap height, color)
display.display();
delay(1000);
if(digitalRead(pinButton) == LOW){
ChangeMac = true;
oldEtatBouton = true;
MainMenu[0] = F("Choix Mac ADD");
Affiche_menu(MainMenu, pos,5,true,3);
byte mainmac[6];
for (int i=0; i<=4 ;i++){
for (int v=0; v<=5 ;v++){
mainmac[v] = KrMac[i][v];
}
MainMenu[i+1] = "";
MainMenu[i+1] += MacToString(mainmac);
}
}
}
void loop() {
if (ChangeMac) {
FoncChangeMac();
} else {
Test();
delay (1000);
}
}
Déjà, un grand merci d'avoir passé du temps à lire ce très long post
Pierre