Browse Source

Move magic numbers and #defines into a header file

main
Hendrik Langer 8 years ago
parent
commit
e1fda0336f
  1. 33
      src/hardware.h
  2. 2
      src/keyboard.h
  3. 3
      src/main.cpp
  4. 4
      src/sdcard.cpp
  5. 3
      src/sound.h

33
src/hardware.h

@ -0,0 +1,33 @@
#ifndef _HARDWARE_H
#define _HARDWARE_H
/* Touch sensors keypad
* PCB Layout: see ESP32 Datasheet A.2. PCB Layout
*/
#define TOUCH_PAD_NUM 10
//Touch0 GPIO 4
//Touch1 GPIO 0 /* don't use: pullup on dev board */
//Touch2 GPIO 2 /* don't use: pullup on dev board */
//Touch3 GPIO15
//Touch4 GPIO13
//Touch5 GPIO12
//Touch6 GPIO14
//Touch7 GPIO27
//Touch8 GPIO33
//Touch9 GPIO32
#define LED_PIN 21
/* SD card
*/
#define PIN_SD_CD 17
#define PIN_SD_CS 5
/* I2S
*/
#define I2S_NUM 0
#define BUF_LENGTH 1024
#endif /* _HARDWARE_H */

2
src/keyboard.h

@ -2,8 +2,8 @@
#define _KEYBOARD_H #define _KEYBOARD_H
#include "driver/touch_pad.h" #include "driver/touch_pad.h"
#include "hardware.h"
#define TOUCH_PAD_NUM 10
static bool s_pad_activated[TOUCH_PAD_NUM]; static bool s_pad_activated[TOUCH_PAD_NUM];

3
src/main.cpp

@ -7,14 +7,13 @@
*/ */
#include "Arduino.h" #include "Arduino.h"
#include "hardware.h"
#include "keyboard.h" #include "keyboard.h"
#include "sdcard.h" #include "sdcard.h"
#include "sound.h" #include "sound.h"
#include "ringbuf.h" #include "ringbuf.h"
#define VERSION "0.0" #define VERSION "0.0"
#define LED_PIN 21
#define BUF_LENGTH 1024
#define WIFI_SSID "ssid" #define WIFI_SSID "ssid"
#define WIFI_PASSWORD "password" #define WIFI_PASSWORD "password"

4
src/sdcard.cpp

@ -10,13 +10,13 @@
#include "SD.h" #include "SD.h"
#include "SPI.h" #include "SPI.h"
#include "hardware.h"
#include "sdcard.h" #include "sdcard.h"
#include "sound.h" #include "sound.h"
using namespace std; using namespace std;
static const char* TAG = "SDCard"; static const char* TAG = "SDCard";
#define PIN_SD_CD 17
SDCard::SDCard() { SDCard::SDCard() {
} }
@ -26,7 +26,7 @@ void SDCard::mount() {
if (!digitalRead(PIN_SD_CD)) { if (!digitalRead(PIN_SD_CD)) {
Serial.println("No card detected!"); Serial.println("No card detected!");
} }
if(!SD.begin(5)){ if(!SD.begin(PIN_SD_CS)){
Serial.println("Card Mount Failed"); Serial.println("Card Mount Failed");
return; return;
} }

3
src/sound.h

@ -4,8 +4,7 @@
#include "Arduino.h" #include "Arduino.h"
#include "driver/i2s.h" #include "driver/i2s.h"
#include "hardware.h"
#define I2S_NUM 0
typedef struct { typedef struct {

Loading…
Cancel
Save