Projet pour réaliser un 1 2 3 Soleil automatique.

Dependencies:   mbed mbed-os MAX7219 rtos

Committer:
AubinGOUHIER
Date:
Sun Dec 23 18:16:49 2018 +0000
Revision:
0:f16dce4818bf
Projet Polytech TOURS DII4A;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AubinGOUHIER 0:f16dce4818bf 1 #include "hearder.h"
AubinGOUHIER 0:f16dce4818bf 2 //#include "mbed.h"
AubinGOUHIER 0:f16dce4818bf 3 //#include "max7219.h"
AubinGOUHIER 0:f16dce4818bf 4
AubinGOUHIER 0:f16dce4818bf 5 Max7219 deviceM(p5, p6, p7,p8);
AubinGOUHIER 0:f16dce4818bf 6
AubinGOUHIER 0:f16dce4818bf 7 int main() {
AubinGOUHIER 0:f16dce4818bf 8
AubinGOUHIER 0:f16dce4818bf 9 max7219_configuration_t cfg = {
AubinGOUHIER 0:f16dce4818bf 10 .device_number = 1,
AubinGOUHIER 0:f16dce4818bf 11 .decode_mode = 0,
AubinGOUHIER 0:f16dce4818bf 12 .intensity = Max7219::MAX7219_INTENSITY_8,
AubinGOUHIER 0:f16dce4818bf 13 .scan_limit = Max7219::MAX7219_SCAN_8
AubinGOUHIER 0:f16dce4818bf 14 };
AubinGOUHIER 0:f16dce4818bf 15 deviceM.init_device(cfg);
AubinGOUHIER 0:f16dce4818bf 16 deviceM.enable_device(1);
AubinGOUHIER 0:f16dce4818bf 17 deviceM.set_display_test();
AubinGOUHIER 0:f16dce4818bf 18 wait_ms(500);
AubinGOUHIER 0:f16dce4818bf 19 deviceM.clear_display_test();
AubinGOUHIER 0:f16dce4818bf 20 wait_ms(500);
AubinGOUHIER 0:f16dce4818bf 21
AubinGOUHIER 0:f16dce4818bf 22 while(1)
AubinGOUHIER 0:f16dce4818bf 23 {
AubinGOUHIER 0:f16dce4818bf 24 Aff(deviceM);
AubinGOUHIER 0:f16dce4818bf 25 }
AubinGOUHIER 0:f16dce4818bf 26 }
AubinGOUHIER 0:f16dce4818bf 27
AubinGOUHIER 0:f16dce4818bf 28 void Gagner(Max7219 deviceM)
AubinGOUHIER 0:f16dce4818bf 29 {
AubinGOUHIER 0:f16dce4818bf 30 deviceM.write_digit(1,1,0b00000000);
AubinGOUHIER 0:f16dce4818bf 31 deviceM.write_digit(1,2,0b01100100);
AubinGOUHIER 0:f16dce4818bf 32 deviceM.write_digit(1,3,0b01100010);
AubinGOUHIER 0:f16dce4818bf 33 deviceM.write_digit(1,4,0b00000010);
AubinGOUHIER 0:f16dce4818bf 34 deviceM.write_digit(1,5,0b00000010);
AubinGOUHIER 0:f16dce4818bf 35 deviceM.write_digit(1,6,0b01100010);
AubinGOUHIER 0:f16dce4818bf 36 deviceM.write_digit(1,7,0b01100100);
AubinGOUHIER 0:f16dce4818bf 37 deviceM.write_digit(1,8,0b00000000);
AubinGOUHIER 0:f16dce4818bf 38 }
AubinGOUHIER 0:f16dce4818bf 39
AubinGOUHIER 0:f16dce4818bf 40 void Perdu(Max7219 deviceM)
AubinGOUHIER 0:f16dce4818bf 41 {
AubinGOUHIER 0:f16dce4818bf 42 deviceM.write_digit(1,1,0b00000000);
AubinGOUHIER 0:f16dce4818bf 43 deviceM.write_digit(1,2,0b01100010);
AubinGOUHIER 0:f16dce4818bf 44 deviceM.write_digit(1,3,0b01100100);
AubinGOUHIER 0:f16dce4818bf 45 deviceM.write_digit(1,4,0b00000100);
AubinGOUHIER 0:f16dce4818bf 46 deviceM.write_digit(1,5,0b00000100);
AubinGOUHIER 0:f16dce4818bf 47 deviceM.write_digit(1,6,0b01100100);
AubinGOUHIER 0:f16dce4818bf 48 deviceM.write_digit(1,7,0b01100010);
AubinGOUHIER 0:f16dce4818bf 49 deviceM.write_digit(1,8,0b00000000);
AubinGOUHIER 0:f16dce4818bf 50 }
AubinGOUHIER 0:f16dce4818bf 51 void Soleil(Max7219 deviceM)
AubinGOUHIER 0:f16dce4818bf 52 {
AubinGOUHIER 0:f16dce4818bf 53 deviceM.write_digit(1,1,0b00000000);
AubinGOUHIER 0:f16dce4818bf 54 deviceM.write_digit(1,2,0b00000000);
AubinGOUHIER 0:f16dce4818bf 55 deviceM.write_digit(1,3,0b00000000);
AubinGOUHIER 0:f16dce4818bf 56 deviceM.write_digit(1,4,0b01111110);
AubinGOUHIER 0:f16dce4818bf 57 deviceM.write_digit(1,5,0b01111110);
AubinGOUHIER 0:f16dce4818bf 58 deviceM.write_digit(1,6,0b00000000);
AubinGOUHIER 0:f16dce4818bf 59 deviceM.write_digit(1,7,0b00000000);
AubinGOUHIER 0:f16dce4818bf 60 deviceM.write_digit(1,8,0b00000000);
AubinGOUHIER 0:f16dce4818bf 61
AubinGOUHIER 0:f16dce4818bf 62 wait_ms(500);
AubinGOUHIER 0:f16dce4818bf 63
AubinGOUHIER 0:f16dce4818bf 64 deviceM.write_digit(1,1,0b00000000);
AubinGOUHIER 0:f16dce4818bf 65 deviceM.write_digit(1,2,0b00000000);
AubinGOUHIER 0:f16dce4818bf 66 deviceM.write_digit(1,3,0b01100010);
AubinGOUHIER 0:f16dce4818bf 67 deviceM.write_digit(1,4,0b01010010);
AubinGOUHIER 0:f16dce4818bf 68 deviceM.write_digit(1,5,0b01001010);
AubinGOUHIER 0:f16dce4818bf 69 deviceM.write_digit(1,6,0b01000110);
AubinGOUHIER 0:f16dce4818bf 70 deviceM.write_digit(1,7,0b00000000);
AubinGOUHIER 0:f16dce4818bf 71 deviceM.write_digit(1,8,0b00000000);
AubinGOUHIER 0:f16dce4818bf 72
AubinGOUHIER 0:f16dce4818bf 73 wait_ms(500);
AubinGOUHIER 0:f16dce4818bf 74
AubinGOUHIER 0:f16dce4818bf 75 deviceM.write_digit(1,1,0b00000000);
AubinGOUHIER 0:f16dce4818bf 76 deviceM.write_digit(1,2,0b00000000);
AubinGOUHIER 0:f16dce4818bf 77 deviceM.write_digit(1,3,0b01111110);
AubinGOUHIER 0:f16dce4818bf 78 deviceM.write_digit(1,4,0b01011010);
AubinGOUHIER 0:f16dce4818bf 79 deviceM.write_digit(1,5,0b01011010);
AubinGOUHIER 0:f16dce4818bf 80 deviceM.write_digit(1,6,0b01000010);
AubinGOUHIER 0:f16dce4818bf 81 deviceM.write_digit(1,7,0b00000000);
AubinGOUHIER 0:f16dce4818bf 82 deviceM.write_digit(1,8,0b00000000);
AubinGOUHIER 0:f16dce4818bf 83
AubinGOUHIER 0:f16dce4818bf 84 wait_ms(500);
AubinGOUHIER 0:f16dce4818bf 85
AubinGOUHIER 0:f16dce4818bf 86 deviceM.write_digit(1,1,0b10000001);
AubinGOUHIER 0:f16dce4818bf 87 deviceM.write_digit(1,2,0b01000010);
AubinGOUHIER 0:f16dce4818bf 88 deviceM.write_digit(1,3,0b00111100);
AubinGOUHIER 0:f16dce4818bf 89 deviceM.write_digit(1,4,0b01111110);
AubinGOUHIER 0:f16dce4818bf 90 deviceM.write_digit(1,5,0b01111110);
AubinGOUHIER 0:f16dce4818bf 91 deviceM.write_digit(1,6,0b00111100);
AubinGOUHIER 0:f16dce4818bf 92 deviceM.write_digit(1,7,0b01000010);
AubinGOUHIER 0:f16dce4818bf 93 deviceM.write_digit(1,8,0b10000001);
AubinGOUHIER 0:f16dce4818bf 94 }
AubinGOUHIER 0:f16dce4818bf 95 void Clear(Max7219 deviceM)
AubinGOUHIER 0:f16dce4818bf 96 {
AubinGOUHIER 0:f16dce4818bf 97 deviceM.write_digit(1,1,0b00000000);
AubinGOUHIER 0:f16dce4818bf 98 deviceM.write_digit(1,2,0b00000000);
AubinGOUHIER 0:f16dce4818bf 99 deviceM.write_digit(1,3,0b00000000);
AubinGOUHIER 0:f16dce4818bf 100 deviceM.write_digit(1,4,0b00000000);
AubinGOUHIER 0:f16dce4818bf 101 deviceM.write_digit(1,5,0b00000000);
AubinGOUHIER 0:f16dce4818bf 102 deviceM.write_digit(1,6,0b01000010);
AubinGOUHIER 0:f16dce4818bf 103 deviceM.write_digit(1,7,0b00000000);
AubinGOUHIER 0:f16dce4818bf 104 deviceM.write_digit(1,8,0b00000000);
AubinGOUHIER 0:f16dce4818bf 105 }
AubinGOUHIER 0:f16dce4818bf 106
AubinGOUHIER 0:f16dce4818bf 107 void Aff(Max7219 deviceM)
AubinGOUHIER 0:f16dce4818bf 108 {
AubinGOUHIER 0:f16dce4818bf 109 deviceM.write_digit(1,1,0b00000000);
AubinGOUHIER 0:f16dce4818bf 110 deviceM.write_digit(1,2,0b01100100);
AubinGOUHIER 0:f16dce4818bf 111 deviceM.write_digit(1,3,0b01100010);
AubinGOUHIER 0:f16dce4818bf 112 deviceM.write_digit(1,4,0b00000010);
AubinGOUHIER 0:f16dce4818bf 113 deviceM.write_digit(1,5,0b00000010);
AubinGOUHIER 0:f16dce4818bf 114 deviceM.write_digit(1,6,0b01100010);
AubinGOUHIER 0:f16dce4818bf 115 deviceM.write_digit(1,7,0b01100100);
AubinGOUHIER 0:f16dce4818bf 116 deviceM.write_digit(1,8,0b00000000);
AubinGOUHIER 0:f16dce4818bf 117
AubinGOUHIER 0:f16dce4818bf 118 wait(1);
AubinGOUHIER 0:f16dce4818bf 119
AubinGOUHIER 0:f16dce4818bf 120 deviceM.write_digit(1,1,0b00000000);
AubinGOUHIER 0:f16dce4818bf 121 deviceM.write_digit(1,2,0b01100010);
AubinGOUHIER 0:f16dce4818bf 122 deviceM.write_digit(1,3,0b01100100);
AubinGOUHIER 0:f16dce4818bf 123 deviceM.write_digit(1,4,0b00000100);
AubinGOUHIER 0:f16dce4818bf 124 deviceM.write_digit(1,5,0b00000100);
AubinGOUHIER 0:f16dce4818bf 125 deviceM.write_digit(1,6,0b01100100);
AubinGOUHIER 0:f16dce4818bf 126 deviceM.write_digit(1,7,0b01100010);
AubinGOUHIER 0:f16dce4818bf 127 deviceM.write_digit(1,8,0b00000000);
AubinGOUHIER 0:f16dce4818bf 128
AubinGOUHIER 0:f16dce4818bf 129 wait(1);
AubinGOUHIER 0:f16dce4818bf 130
AubinGOUHIER 0:f16dce4818bf 131 deviceM.write_digit(1,1,0b00000000);
AubinGOUHIER 0:f16dce4818bf 132 deviceM.write_digit(1,2,0b00000000);
AubinGOUHIER 0:f16dce4818bf 133 deviceM.write_digit(1,3,0b00000000);
AubinGOUHIER 0:f16dce4818bf 134 deviceM.write_digit(1,4,0b01111110);
AubinGOUHIER 0:f16dce4818bf 135 deviceM.write_digit(1,5,0b01111110);
AubinGOUHIER 0:f16dce4818bf 136 deviceM.write_digit(1,6,0b00000000);
AubinGOUHIER 0:f16dce4818bf 137 deviceM.write_digit(1,7,0b00000000);
AubinGOUHIER 0:f16dce4818bf 138 deviceM.write_digit(1,8,0b00000000);
AubinGOUHIER 0:f16dce4818bf 139
AubinGOUHIER 0:f16dce4818bf 140 wait_ms(500);
AubinGOUHIER 0:f16dce4818bf 141
AubinGOUHIER 0:f16dce4818bf 142 deviceM.write_digit(1,1,0b00000000);
AubinGOUHIER 0:f16dce4818bf 143 deviceM.write_digit(1,2,0b00000000);
AubinGOUHIER 0:f16dce4818bf 144 deviceM.write_digit(1,3,0b01100010);
AubinGOUHIER 0:f16dce4818bf 145 deviceM.write_digit(1,4,0b01010010);
AubinGOUHIER 0:f16dce4818bf 146 deviceM.write_digit(1,5,0b01001010);
AubinGOUHIER 0:f16dce4818bf 147 deviceM.write_digit(1,6,0b01000110);
AubinGOUHIER 0:f16dce4818bf 148 deviceM.write_digit(1,7,0b00000000);
AubinGOUHIER 0:f16dce4818bf 149 deviceM.write_digit(1,8,0b00000000);
AubinGOUHIER 0:f16dce4818bf 150
AubinGOUHIER 0:f16dce4818bf 151 wait_ms(500);
AubinGOUHIER 0:f16dce4818bf 152
AubinGOUHIER 0:f16dce4818bf 153 deviceM.write_digit(1,1,0b00000000);
AubinGOUHIER 0:f16dce4818bf 154 deviceM.write_digit(1,2,0b00000000);
AubinGOUHIER 0:f16dce4818bf 155 deviceM.write_digit(1,3,0b01111110);
AubinGOUHIER 0:f16dce4818bf 156 deviceM.write_digit(1,4,0b01011010);
AubinGOUHIER 0:f16dce4818bf 157 deviceM.write_digit(1,5,0b01011010);
AubinGOUHIER 0:f16dce4818bf 158 deviceM.write_digit(1,6,0b01000010);
AubinGOUHIER 0:f16dce4818bf 159 deviceM.write_digit(1,7,0b00000000);
AubinGOUHIER 0:f16dce4818bf 160 deviceM.write_digit(1,8,0b00000000);
AubinGOUHIER 0:f16dce4818bf 161
AubinGOUHIER 0:f16dce4818bf 162 wait_ms(500);
AubinGOUHIER 0:f16dce4818bf 163
AubinGOUHIER 0:f16dce4818bf 164 deviceM.write_digit(1,1,0b10000001);
AubinGOUHIER 0:f16dce4818bf 165 deviceM.write_digit(1,2,0b01000010);
AubinGOUHIER 0:f16dce4818bf 166 deviceM.write_digit(1,3,0b00111100);
AubinGOUHIER 0:f16dce4818bf 167 deviceM.write_digit(1,4,0b01111110);
AubinGOUHIER 0:f16dce4818bf 168 deviceM.write_digit(1,5,0b01111110);
AubinGOUHIER 0:f16dce4818bf 169 deviceM.write_digit(1,6,0b00111100);
AubinGOUHIER 0:f16dce4818bf 170 deviceM.write_digit(1,7,0b01000010);
AubinGOUHIER 0:f16dce4818bf 171 deviceM.write_digit(1,8,0b10000001);
AubinGOUHIER 0:f16dce4818bf 172
AubinGOUHIER 0:f16dce4818bf 173 wait(1);
AubinGOUHIER 0:f16dce4818bf 174 deviceM.write_digit(1,1,0b00000000);
AubinGOUHIER 0:f16dce4818bf 175 deviceM.write_digit(1,2,0b00000000);
AubinGOUHIER 0:f16dce4818bf 176 deviceM.write_digit(1,3,0b00000000);
AubinGOUHIER 0:f16dce4818bf 177 deviceM.write_digit(1,4,0b00000000);
AubinGOUHIER 0:f16dce4818bf 178 deviceM.write_digit(1,5,0b00000000);
AubinGOUHIER 0:f16dce4818bf 179 deviceM.write_digit(1,6,0b00000000);
AubinGOUHIER 0:f16dce4818bf 180 deviceM.write_digit(1,7,0b00000000);
AubinGOUHIER 0:f16dce4818bf 181 deviceM.write_digit(1,8,0b00000000);
AubinGOUHIER 0:f16dce4818bf 182
AubinGOUHIER 0:f16dce4818bf 183 }