Changes between Version 6 and Version 7 of SujetTP7-2016


Ignore:
Timestamp:
Mar 29, 2016, 9:21:22 PM (9 years ago)
Author:
franck
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SujetTP7-2016

    v6 v7  
    3131    Il s'agit de l'adresse de l'écran sur le bus I2C.
    3232
    33 * Vous allez utiliser l'écran pour afficher la valeur de la photorésistance après une mise à
     33* Dans l'exemple ci-dessous, nous avons deux tâches communicantes.
     34  * Lumi allez utiliser l'écran pour afficher la valeur de la photorésistance après une mise à
    3435  l'échelle entre 0 et 100.
    3536
     
    6667}
    6768
    68 // Configuration des broches
     69// ------------- Configuration des broches
     70
    6971#define PIN_LUMI 1
    7072#define OLED_RESET 4
    7173Adafruit_SSD1306 display(OLED_RESET);
    7274
    73 // Variables globales pour la communication inter-taches
     75// ------------- Variables globales pour la communication inter-taches
     76
    7477byte lumi, lumiFull;
     78
     79// ------------- Déclaration des tâches
     80
     81void Lumi ( // Echantillonne périodiquement le capteur de lumière et rend sa valeur entre 0 et 99
     82   int timer, unsigned long period, // tâche périodique
     83   byte pin,                        // numéro de la broche lue
     84   byte *lumi,                      // valeur lue comprise entre 0 et 99
     85   byte *lumiFull                   // drapeau mis à 1 à chaque période après écriture dans lumi
     86);
     87
     88void Oled1 ( // Affichage de la lumiere                         
     89   byte *mess,                      // buffer à afficher
     90   byte *full                       // drapeau mis à 1 pour demander l'affichage
     91);
     92
     93// ------------- Configuration de l'application et des périphériques
     94
     95void setup() {
     96  Serial.begin(115200);
     97  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x32)
     98  display.clearDisplay();
     99  display.setTextSize(1);
     100  display.setTextColor(WHITE);
     101}
     102
     103// ------------- Connexion des tâches
     104
     105void loop() {
     106  Lumi (0,1000000, PIN_LUMI, &lumi, &lumiFull); 
     107  Oled1 (&lumi, &lumiFull);
     108}
     109
     110// ------------- Définition des tâches
    75111
    76112void Lumi (int timer, unsigned long period, byte pin, byte *lumi, byte *lumiFull)
     
    91127  display.display();
    92128}
    93 
    94 void setup() {
    95   Serial.begin(115200);
    96   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x32)
    97   display.clearDisplay();
    98   display.setTextSize(1);
    99   display.setTextColor(WHITE);
    100 }
    101 
    102 void loop() {
    103   Lumi (0,1000000, PIN_LUMI, &lumi, &lumiFull); 
    104   Oled1 (&lumi, &lumiFull);
    105 }
    106129}}}