jules_verne

Ceci est une ancienne révision du document !


La totalité du projet sera documentée, mais pour l'instant, prise de note !

Transcodex graphique

→ dans le raspberryPi, pour lancer le script python automatiquement: login automatique en CLI Ajouter dans .bashrc les deux lignes suivantes: cd /home/pi/git/py-thermal-printer /usr/bin/python /home/pi/git/py-thermal-printer/codex.py

→ le script python:

→ dans le clavier en kapla, un arduino Leonardo:

#include <Keypad.h> #include <Adafruit_NeoPixel.h>

Which pin on the Arduino is connected to the NeoPixels? On a Trinket or Gemma we suggest changing this to 1 #define PIN 13

How many NeoPixels are attached to the Arduino? #define NUMPIXELS 14 When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals. Note that for older NeoPixel strips you might need to change the third parameter–see the strandtest example for more information on possible values. Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 13500; delay for half a second const int spacePin = 12; the number of the pushbutton pin int buttonPressed = 0; variable for reading the pushbutton status int printing = 0; const byte ROWS = 6; four rows const byte COLS = 6; three columns char keys[ROWS][COLS] = { {'0', '1', '2', '3', '4', '5'}, {'A', 'B', 'C', 'D', 'E', 'F'}, {'N', 'O', 'P', 'Q', 'R', 'S'}, {'T', 'U', 'V', 'W', 'X', 'Y'}, {'G', 'H', 'I', 'J', 'K', 'L'}, {'6', '7', '8', '9', 'M', 'Z'} }; byte rowPins[ROWS] = {6, 7, 8, 9, 10, 11}; connect to the row pinouts of the keypad byte colPins[COLS] = {0, 1, 2, 3, 4, 5}; connect to the column pinouts of the keypad Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); void setup() { pixels.begin(); This initializes the NeoPixel library.

Keyboard.begin();
pinMode(spacePin, INPUT_PULLUP);
//Serial.begin(9600);

}

void loop() {

if (printing == 0)
{
  lightsGreen();
  int sensorVal = digitalRead(12);
  if (sensorVal == LOW && buttonPressed == 0) {
    buttonPressed = 1;
    //Serial.println("SPACE");
    Keyboard.write(0x20);
    Keyboard.releaseAll();  
    printing = 1;
    lightsRed();
    delay(delayval); // Delay for a period of time (in milliseconds).
    Keyboard.write(0x20);
    Keyboard.releaseAll(); 
    delay(200);
    Keyboard.write(0xB0);
    Keyboard.releaseAll(); 
    delay(200);
    printing = 0;
  } else if (sensorVal == HIGH && buttonPressed == 1) {
    buttonPressed = 0;
  }
  
  char key = keypad.getKey();
  if (key) {
    //Serial.println(key);
    Keyboard.write(key);
    Keyboard.releaseAll();  
    printing = 1;
    lightsRed();
    delay(delayval); // Delay for a period of time (in milliseconds).
    Keyboard.write(key);
    Keyboard.releaseAll(); 
    delay(200);
    Keyboard.write(0xB0);
    Keyboard.releaseAll(); 
    delay(200);
    printing = 0;
  }
}

}

void lightsGreen() {

for (int i = 0; i < NUMPIXELS; i++) {
  // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
  pixels.setPixelColor(i, pixels.Color(0, 255, 0)); // Moderately bright green color.
  pixels.show(); // This sends the updated pixel color to the hardware.
}

}

void lightsRed() {

for (int i = 0; i < NUMPIXELS; i++) {
  // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
  pixels.setPixelColor(i, pixels.Color(255, 0, 0)); // Moderately bright green color.
  pixels.show(); // This sends the updated pixel color to the hardware.
}

}

  • jules_verne.1455831485.txt.gz
  • Dernière modification: 2016/03/04 08:06
  • (modification externe)