Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| projekte:dot-matrix-display [2016-07-01 06:20] – [aktuelle Arbeit daran] cracki | projekte:dot-matrix-display [2017-01-17 01:01] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 10: | Line 10: | ||
| Zwei Dot Matrix Panels aus China, 32x16 Pixel Rot, 10 mm Pitch (P10). Keine Ahnung, wem die gehören. | Zwei Dot Matrix Panels aus China, 32x16 Pixel Rot, 10 mm Pitch (P10). Keine Ahnung, wem die gehören. | ||
| - | Arduino, Steckbrett, Netzteil sind Clubbesitz/ | + | Arduino, ESP8266 NodeMCU Devboard, Steckbrett, Netzteil sind Clubbesitz/ |
| * http:// | * http:// | ||
| Line 17: | Line 17: | ||
| * https:// | * https:// | ||
| - | ===== aktuelle Arbeit daran ==== | + | ===== Pinbelegungen ===== |
| - | * mx hackt eine python library, wodurch Pixel [gegeben durch (x,y)] manipuliert werden kann | + | |
| - | * mx will dann pixelflut und ähnliches laufen lassen | + | |
| - | Example Code mit Noise, gerade genug um es am laufen zu halten: | + | * 1: Output Enable (PWM-fähig) |
| - | < | + | * 2: A mux |
| - | /* | + | * 4: B mux |
| - | | + | |
| + | * 10: Store Clock (SPI select) | ||
| + | * 12: R (SPI mosi) | ||
| - | Simulates Conway' | + | ===== Implementierung ===== |
| - | https:// | + | |
| - | */ | + | |
| - | #include <SPI.h> | + | * modifizierte DMD2: https:// |
| - | #include <DMD2.h> | + | * arduino sketch und lua script https:// |
| + | * TCP pixelflut kommt *vielleicht* noch. wer ne implementierung in NodeMCU-Lua anschleppt | ||
| - | // How many displays do you have? | + | ==== MQTT Endpunkte ==== |
| - | const int WIDTH = 2; | + | |
| - | const int HEIGHT | + | |
| - | SPIDMD dmd(WIDTH,HEIGHT); | + | * runlevel : shutdown/ |
| + | * kontrolliert, ob gameoflife laeuft oder alles aus | ||
| + | * cracki/ | ||
| + | * reset : | ||
| + | * " | ||
| + | * alles andere resettet den ganzen Apparat | ||
| + | * solid : 0/1/255 | ||
| + | * 0 und 1 setzen die pixel auf 0 oder 1 | ||
| + | * 255 invertiert alles | ||
| + | * dutycycle : 0-255 | ||
| + | * sollte man nicht uebertreiben, | ||
| + | * pixelflut : PX <x> <y> < | ||
| + | * bitmap : 128 bytes | ||
| + | * text : Text vollhoch | ||
| + | * text1 : Text Zeile 1 | ||
| + | * text2 : Text Zeile 2 | ||
| + | * gameoflife : 0/1 | ||
| + | * gameoflife/ | ||
| + | * gameoflife/ | ||
| - | void populate_random_cells() { | + | ==== Pinbelegungen ==== |
| - | // Populate the initial display randomly | + | |
| - | for(int x = 0; x < dmd.width; x++) { | + | |
| - | for(int y = 0; y < dmd.height; y++) { | + | |
| - | if(random(100) < 30) // Increase 30 to a higher number to set more initial pixels | + | |
| - | dmd.setPixel(x, | + | |
| - | dmd.setPixel(x, | + | |
| - | } | + | |
| - | } | + | |
| - | } | + | |
| - | // the setup routine runs once when you press reset: | + | Panel -> Arduino: |
| - | void setup() { | + | * 1 -> D9 (mit 100k pulldown, sonst legen die panels los, ueberlasten das netzteil, spannung am arsch, arduino kommt nicht hoch) |
| - | | + | |
| - | | + | |
| - | | + | |
| + | * 12 -> D11 | ||
| - | randomSeed(analogRead(0)); | + | Arduino mit ESP fuer netzwerk: |
| - | | + | |
| - | } | + | * TXD <- ESP RXD0 |
| + | * reset <- ESP D2 | ||
| + | * GND und VCC passend | ||
| - | // the loop routine runs over and over again forever: | + | ESP als netzwerksklave an Arduino: |
| - | void loop() { | + | * erde, vcc |
| - | | + | * TXD0 -> Arduino RX |
| - | | + | |
| + | | ||
| - | long start = millis(); | + | ungetestete alternative, |
| + | * 2 (A mux) -> D1 | ||
| + | * 4 (B mux) -> D2 | ||
| + | * 1 (OE) -> D3 (sollte PWM koennen) | ||
| + | * 8 (SPI clock) -> D5 (HSCLK) | ||
| + | * 10 (store pulse) -> D0 (gpio) | ||
| + | * 12 (R) -> D7 (HMOSI) | ||
| - | // random seed | ||
| - | for (int k = 13; k > 0; k -= 1) | ||
| - | current_generation.setPixel(random(dmd.width), | ||
| - | // Update next generation of every pixel | ||
| - | bool change = false; | ||
| - | for(int x = 0; x < dmd.width; x++) { | ||
| - | for(int y = 0; y < dmd.height; y++) { | ||
| - | bool state = current_generation.getPixel(x, | ||
| - | int live_neighbours = 0; | ||
| - | |||
| - | // Count how many live neighbours we have in the current generation | ||
| - | for(int nx = x - 1; nx < x + 2; nx++) { | ||
| - | for(int ny = y - 1; ny < y + 2; ny++) { | ||
| - | if(nx == x && ny == y) | ||
| - | continue; | ||
| - | if(current_generation.getPixel(nx, | ||
| - | live_neighbours++; | ||
| - | } | ||
| - | } | ||
| - | |||
| - | // Update pixel count for the next generation | ||
| - | if(state && (live_neighbours < 2 || live_neighbours > 3)) { | ||
| - | state = false; | ||
| - | change = true; | ||
| - | } | ||
| - | else if(!state && (live_neighbours == 3)) { | ||
| - | state = true; | ||
| - | change = true; | ||
| - | } | ||
| - | dmd.setPixel(x, | ||
| - | } | ||
| - | } | ||
| - | |||
| - | Serial.println(String(" | ||
| - | |||
| - | if(!change && 0) { | ||
| - | // We've made it to an unchanging state | ||
| - | delay(500); | ||
| - | populate_random_cells(); | ||
| - | // (We can't detect steady states where things change forward | ||
| - | // and back, for these you need to press reset!) | ||
| - | } | ||
| - | } | ||
| - | </ | ||