Consistently declare pins with PIN_ constants
This commit is contained in:
parent
2167a03924
commit
80c8f4815c
6 changed files with 49 additions and 30 deletions
|
@ -4,11 +4,11 @@
|
|||
#include "obus_can.h"
|
||||
|
||||
// Chip select for the CAN module
|
||||
#define MCP_CS 8
|
||||
#define PIN_MCP_CS 8
|
||||
|
||||
namespace obus_can {
|
||||
|
||||
MCP2515 mcp2515(MCP_CS);
|
||||
MCP2515 mcp2515(PIN_MCP_CS);
|
||||
bool is_init = false;
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include "obus_can.h"
|
||||
#include "obus_module.h"
|
||||
|
||||
#define RED_LED 4
|
||||
#define GREEN_LED 7
|
||||
#define PIN_LED_RED 4
|
||||
#define PIN_LED_GREEN 7
|
||||
|
||||
#define BLINK_DELAY_SLOW 1000
|
||||
#define BLINK_DELAY_FAST 300
|
||||
|
@ -36,8 +36,8 @@ void _setLed(struct color color) {
|
|||
blink_delay = 0;
|
||||
led_reset_time = 0;
|
||||
|
||||
digitalWrite(RED_LED, color.red ? HIGH : LOW);
|
||||
digitalWrite(GREEN_LED, color.green ? HIGH : LOW);
|
||||
digitalWrite(PIN_LED_RED, color.red ? HIGH : LOW);
|
||||
digitalWrite(PIN_LED_GREEN, color.green ? HIGH : LOW);
|
||||
}
|
||||
|
||||
void _ledLoop() {
|
||||
|
@ -55,11 +55,11 @@ void _ledLoop() {
|
|||
if (blink_delay && millis() > blink_next_time) {
|
||||
blink_led_lit = !blink_led_lit;
|
||||
if (blink_led_lit) {
|
||||
digitalWrite(RED_LED, led_color.red ? HIGH : LOW);
|
||||
digitalWrite(GREEN_LED, led_color.green ? HIGH : LOW);
|
||||
digitalWrite(PIN_LED_RED, led_color.red ? HIGH : LOW);
|
||||
digitalWrite(PIN_LED_GREEN, led_color.green ? HIGH : LOW);
|
||||
} else {
|
||||
digitalWrite(RED_LED, false);
|
||||
digitalWrite(GREEN_LED, false);
|
||||
digitalWrite(PIN_LED_RED, false);
|
||||
digitalWrite(PIN_LED_GREEN, false);
|
||||
}
|
||||
|
||||
blink_next_time = millis() + blink_delay;
|
||||
|
@ -83,8 +83,8 @@ void _resetState() {
|
|||
next_loop_call_deadline = 0;
|
||||
|
||||
if (this_module.type == OBUS_TYPE_PUZZLE || this_module.type == OBUS_TYPE_NEEDY) {
|
||||
pinMode(RED_LED, OUTPUT);
|
||||
pinMode(GREEN_LED, OUTPUT);
|
||||
pinMode(PIN_LED_RED, OUTPUT);
|
||||
pinMode(PIN_LED_GREEN, OUTPUT);
|
||||
|
||||
_setLedBlink(COLOR_GREEN, BLINK_DELAY_SLOW);
|
||||
}
|
||||
|
@ -116,8 +116,8 @@ void empty_callback_state(uint32_t time_left, uint8_t strikes, uint8_t max_strik
|
|||
void blink_error(String message) {
|
||||
bool blink = false;
|
||||
while (true) {
|
||||
digitalWrite(RED_LED, blink);
|
||||
digitalWrite(GREEN_LED, blink);
|
||||
digitalWrite(PIN_LED_RED, blink);
|
||||
digitalWrite(PIN_LED_GREEN, blink);
|
||||
blink = !blink;
|
||||
delay(blink ? BLINK_DELAY_SLOW : BLINK_DELAY_FAST);
|
||||
Serial.println(message);
|
||||
|
|
|
@ -56,11 +56,11 @@ struct obus_can::module this_module = {
|
|||
|
||||
|
||||
// For the display/button chip
|
||||
#define STROBE_TM 4
|
||||
#define CLOCK_TM 6
|
||||
#define DIO_TM 7
|
||||
#define PIN_STROBE_TM 4
|
||||
#define PIN_CLOCK_TM 6
|
||||
#define PIN_DIO_TM 7
|
||||
#define HI_FREQ false // If using a high freq CPU > ~100 MHZ set to true.
|
||||
TM1638plus tm(STROBE_TM, CLOCK_TM, DIO_TM, HI_FREQ);
|
||||
TM1638plus tm(PIN_STROBE_TM, PIN_CLOCK_TM, PIN_DIO_TM, HI_FREQ);
|
||||
|
||||
Debounced startpauseButton;
|
||||
|
||||
|
|
|
@ -4,13 +4,28 @@
|
|||
#include <obus_module.h>
|
||||
#include <LiquidCrystal.h>
|
||||
|
||||
// Pins for the Hitachi HD44780 LCD controller
|
||||
#define PIN_LCD_RS 7 // Register Select. RS=0: Command, RS=1: Data
|
||||
#define PIN_LCD_ENABLE 6 // Enable (aka Clock). A falling edge on this pin triggers execution
|
||||
#define PIN_LCD_D0 5
|
||||
#define PIN_LCD_D1 4
|
||||
#define PIN_LCD_D2 3
|
||||
#define PIN_LCD_D3 2
|
||||
|
||||
#define SERIAL_NUMBER_SIZE 7
|
||||
|
||||
uint8_t serial_number[SERIAL_NUMBER_SIZE];
|
||||
|
||||
// true when we need to update the LCD display
|
||||
bool render_now = false;
|
||||
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
|
||||
LiquidCrystal lcd(
|
||||
PIN_LCD_RS,
|
||||
PIN_LCD_ENABLE,
|
||||
PIN_LCD_D0,
|
||||
PIN_LCD_D1,
|
||||
PIN_LCD_D2,
|
||||
PIN_LCD_D3
|
||||
);
|
||||
|
||||
|
||||
void setup() {
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
#include <obus_module.h>
|
||||
#include <ezButton.h>
|
||||
|
||||
#define SPEAKER_PIN 10
|
||||
#define PIN_GREEN_BUTTON 6
|
||||
#define PIN_SPEAKER 10
|
||||
|
||||
ezButton green_button(6);
|
||||
ezButton green_button(PIN_GREEN_BUTTON);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
@ -49,12 +50,12 @@ void loop() {
|
|||
|
||||
// Play the appropriate sound
|
||||
if (trigger_time && millis() > trigger_time - 15000) {
|
||||
tone(SPEAKER_PIN, 440);
|
||||
tone(PIN_SPEAKER, 440);
|
||||
}
|
||||
else if (trigger_time) {
|
||||
tone(SPEAKER_PIN, 449);
|
||||
tone(PIN_SPEAKER, 449);
|
||||
} else {
|
||||
noTone(SPEAKER_PIN);
|
||||
noTone(PIN_SPEAKER);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,16 +2,19 @@
|
|||
// See the LICENSE file for conditions for copying
|
||||
|
||||
|
||||
// A red button connected to pin 5
|
||||
// A green button connected to pin 6
|
||||
// A blue led (with 330 ohm resistor) connected to pin 9
|
||||
// A red button
|
||||
// A green button
|
||||
// A blue led (with 330 ohm resistor)
|
||||
|
||||
#include <obus_module.h>
|
||||
#include <ezButton.h>
|
||||
|
||||
#define BLUE_LED 9
|
||||
ezButton red_button(5);
|
||||
ezButton green_button(6);
|
||||
#define PIN_RED_BUTTON 5
|
||||
#define PIN_GREEN_BUTTON 6
|
||||
#define PIN_LED_BLUE 9
|
||||
|
||||
ezButton red_button(PIN_RED_BUTTON);
|
||||
ezButton green_button(PIN_GREEN_BUTTON);
|
||||
|
||||
bool blue_state = false;
|
||||
bool checking_input = false;
|
||||
|
|
Loading…
Reference in a new issue