script with 2 inputs and 2 outputs, running in a separate thread Johannes Taelman BSD script.axh Axoloti GPIOC0 * Pin 6 (E) -> Axoloti GPIOC1 * Pin 11 (D4) -> Axoloti GPIOC2 * Pin 12 (D5) -> Axoloti GPIOC2 * Pin 13 (D6) -> Axoloti GPIOC2 * Pin 14 (D7) -> Axoloti GPIOC2 * * 5V to pin 2, GND to pin 1, 5 and 16 * Wiper of a pot to pin 3 for contrast with the other pins to gnd and 5V * (for contrast) * Pin 15 to 5V through a 100 ohm resistor * * Pins 7, 8, 9, 10 - unused */ /** DISPLAY UPDATE **/ bool init_trig; static msg_t DisplayUpdate(void *arg) { ((attr_parent *)arg)->DisplayUpdateThread(); } WORKING_AREA(waDisplayUpdate, 1024); Thread *DisplayThd; char msgbuf[2*16]; msg_t DisplayUpdateThread(void) { while(!chThdShouldTerminate()){ lcd_set_pos(0,0); lcd_write_line(&msgbuf[0]); lcd_set_pos(0,1); lcd_write_line(&msgbuf[16]); chThdSleepMilliseconds(50); } chThdExit((msg_t)0); } #define LCD_PIN_BANK GPIOC #define LCD_PIN_RS 0 #define LCD_PIN_E 1 const int LCD_DATA_PINS[4] = { 2, 3, 4, 5 }; inline void lcd_write_line(char *line) { for (int i = 0; i <= 16; i++) { char c = line[i]; lcd_write_word(false, c ? c : ' '); } } inline void lcd_set_pos(int x, int y) { int pos = (y>0) ? 0x40 : 0x0; pos += x; lcd_write_word(true, 0x80 | pos); } inline void lcd_pin_high(int pin) { palWritePad(LCD_PIN_BANK, pin, 1); } inline void lcd_pin_low(int pin) { palWritePad(LCD_PIN_BANK, pin, 0); } inline void lcd_set_bus(uint8_t nibble) { for (int i = 0; i < 4; i++) { palWritePad(LCD_PIN_BANK, LCD_DATA_PINS[i], (nibble&1<>4); lcd_wiggle_e(); lcd_set_bus(word&0x0f); lcd_wiggle_e(); lcd_pin_low(LCD_PIN_RS); } void lcd_init() { palSetPadMode(LCD_PIN_BANK, LCD_PIN_E, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(LCD_PIN_BANK, LCD_PIN_RS, PAL_MODE_OUTPUT_PUSHPULL); for (int i = 0; i < 4; i++) { palSetPadMode(LCD_PIN_BANK, LCD_DATA_PINS[i], PAL_MODE_OUTPUT_PUSHPULL); } chThdSleepMilliseconds(10); lcd_pin_low(LCD_PIN_RS); lcd_set_bus(0b0010); lcd_wiggle_e(); chThdSleepMilliseconds(10); lcd_write_word(true, 0b10); lcd_write_word(true, 0b1100); }]]> 0; i--) { int base = bases[i-1]; int digit = tmp/base; tmp -= digit*base; str[digits-i] = digit + '0'; } }]]> >19, 3, (char *)&inlet_buffer[(attr_line * 16) + attr_pos]); } outlet_ptr = (char *)&inlet_buffer[(attr_line * 16) + attr_pos];]]> no 699 18 688 658