This is an old revision of the document!


Dot Matrix Display

Dot Matrix Display
Inventar Gegenstand im Inventar
Kontakt cracki
Status aktiv (2016-06-28 09:01)

Zwei Dot Matrix Panels aus China, 32×16 Pixel Rot, 10 mm Pitch (P10). Keine Ahnung, wem die gehören.

Arduino, Steckbrett, Netzteil sind Clubbesitz/Getränkekasse.

Pinbelegungen

  • 1: Output Enable (PWM-fähig)
  • 2: A mux
  • 4: B mux
  • 8: Shift Clock (SPI clock)
  • 10: Store Clock (SPI select)
  • 12: R (SPI mosi)

Arduino:

  • 1 → D9
  • 2 → D6
  • 4 → D7
  • 8 → D13
  • 10 → D8
  • 12 → D11

ESP:

  • 1 → D3 (weil D0 scheinbar kein PWM darf?)
  • 2 → D1
  • 4 → D2
  • 8 → GPIO 14 / D5
  • 10 → GPIO 15 / D8 (soll nen 4k7 pulldown kriegen, fuer startup mode selection)
  • 12 → GPIO 13 / D7

aktuelle Arbeit daran

  • 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:

/*
  Game of Life display

  Simulates Conway's Game of Life
  https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
 */

#include <SPI.h>
#include <DMD2.h>

// How many displays do you have?
const int WIDTH = 2;
const int HEIGHT = 1;

SPIDMD dmd(WIDTH,HEIGHT);

void populate_random_cells() {
  // 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,y,GRAPHICS_ON);
      dmd.setPixel(x,y,GRAPHICS_OFF);
    }
  }
}

// the setup routine runs once when you press reset:
void setup() {
  Serial.begin(9600);
  dmd.setBrightness(50);
  dmd.begin();

  randomSeed(analogRead(0));
  populate_random_cells();
}

// the loop routine runs over and over again forever:
void loop() {
  // Store the current generation by copying the current DMD frame contents
  DMDFrame current_generation(dmd);

  long start = millis();

  // random seed
  for (int k = 13; k > 0; k -= 1)
    current_generation.setPixel(random(dmd.width), random(dmd.height), GRAPHICS_ON);

  // 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,y);
      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,ny))
            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,y,state ? GRAPHICS_ON : GRAPHICS_OFF);
    }
  }

  Serial.println(String("Generation time: ") + (millis() - start) + " ms");

  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!)
  }
}
Navigation



You are not allowed to add pages