Merge pull request #7 from Block-Party-VR/2-electrical-schematics-v1-design-fixes

2 electrical schematics v1 design fixes
This commit is contained in:
Quinn
2024-08-20 11:27:48 -04:00
committed by GitHub
15 changed files with 1941 additions and 1686 deletions

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "lib/SerialMessage"]
path = lib/SerialMessage
url = https://github.com/Cynopolis/SerialMessage.git

View File

@@ -52,6 +52,9 @@ wiring diagram for the cube is in the `documentation` directory.
- Adafruits Neopixel library
- Arduino libraries
### Bluetooth Module
On v0.1 of the baord, a seperate bluetooth module (HC-05) is being used for bluetooth. This module needs to be programmed when first plugged in. To program the module, disconnect it from power and hold the "EN" button on the module. (The button should be the only button on the HC-05 module). While still holding down the button, reconnect the module to the ESP32 and press the ESP32's reset button. Wait 5 seconds while still holding down the "EN" button on the module, then release the button, power cycle the module, and you're done.
## Run
- Power up the board and pair it with the headset over bluetooth.
- Build and load the Unity project to the headset.
@@ -112,7 +115,7 @@ Description Set the colors for one of the stacks.
- Red1, Green1, Blue1 correspond with the color of the first cube in the stack and so on. These values can be between 0-255.
You can add as many colors as you want, but they wont display if the corresponding cube doesn't physically exist.
### COmmand Name: `GoToIdle`
### Command Name: `GoToIdle`
Command Number: `3`
Format Example `!3;`

View File

@@ -37,9 +37,9 @@
"other_text_thickness": 0.15,
"other_text_upright": false,
"pads": {
"drill": 0.762,
"height": 1.524,
"width": 1.524
"drill": 0.0,
"height": 0.8,
"width": 1.65
},
"silk_line_width": 0.15,
"silk_text_italic": false,

View File

@@ -1,4 +1,4 @@
23051446609431364
23125258825931219
2p 3
691214110002S
<b>WR-TBL Serie 2141S - 3.50 mm Horizontal Entry Modular w. Rising Cage Clamp<br></b>Max Height =9.1mm , Pitch 3.5mm , 2 Pins
@@ -67227,6 +67227,307 @@ DIL DIP PDIP 2.54mm 7.62mm 300mil
0
4
4
PCM_Espressif
ESP32-C3-DevKitC-02
0
30
30
PCM_Espressif
ESP32-C3-DevKitM-1
0
30
30
PCM_Espressif
ESP32-C3-MINI-1
ESP32-C3-MINI-1: https://www.espressif.com/sites/default/files/documentation/esp32-c3-mini-1_datasheet_en.pdf
ESP32-C3
0
61
53
PCM_Espressif
ESP32-C3-MINI-1U
ESP32-C3-MINI-1U: https://www.espressif.com/sites/default/files/documentation/esp32-c3-mini-1_datasheet_en.pdf
ESP32-C3
0
61
53
PCM_Espressif
ESP32-C3-MINI-1_HandSoldering
ESP32-C3-MINI-1: https://www.espressif.com/sites/default/files/documentation/esp32-c3-mini-1_datasheet_en.pdf
ESP32-C3
0
61
53
PCM_Espressif
ESP32-C3-WROOM-02
ESP32-C3-WROOM-02: https://www.espressif.com/sites/default/files/documentation/esp32-c3-wroom-02_datasheet_en.pdf
ESP32-C3
0
27
19
PCM_Espressif
ESP32-C3-WROOM-02U
ESP32-C3-WROOM-02: https://www.espressif.com/sites/default/files/documentation/esp32-c3-wroom-02_datasheet_en.pdf
ESP32-C3
0
27
19
PCM_Espressif
ESP32-C6-DevKitC-1
ESP32-C6 general-purpose development board, based on ESP32-2-WROOM-1,It has all the ESP32-C6 pins exposed and is easy to connect and use.
ESP32-C6
0
32
32
PCM_Espressif
ESP32-C6-DevKitM-1
ESP32-C6 general-purpose development board, based on ESP32-2-WROOM-1,It has all the ESP32-C6 pins exposed and is easy to connect and use.
ESP32-C6
0
30
30
PCM_Espressif
ESP32-C6-MINI-1
ESP32-C6-MINI-1: https://www.espressif.com/sites/default/files/documentation/esp32-c6-mini-1_datasheet_en.pdf
ESP32-C6
0
61
53
PCM_Espressif
ESP32-C6-MINI-1U
ESP32-C6-MINI-1U: https://www.espressif.com/sites/default/files/documentation/esp32-c6-mini-1_datasheet_en.pdf
ESP32-C6
0
61
53
PCM_Espressif
ESP32-C6-WROOM-1
ESP32-C6-WROOM-1: https://www.espressif.com/sites/default/files/documentation/esp32-c6-wroom-1_datasheet_en.pdf
esp32-c6
0
37
29
PCM_Espressif
ESP32-C6-WROOM-1U
ESP32-C6-WROOM-1U: https://www.espressif.com/sites/default/files/documentation/esp32-c6-wroom-1_wroom-1u_datasheet_en.pdf
esp32-c6
0
37
29
PCM_Espressif
ESP32-DevKitC
ESP32-DevKitC: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/esp32/get-started-devkitc.html
ESP32
0
38
38
PCM_Espressif
ESP32-H2-MINI-1
ESP32-H2-MINI-1: https://www.espressif.com/sites/default/files/documentation/esp32-h2-mini-1_mini-1u_datasheet_en.pdf
ESP32-H2
0
61
53
PCM_Espressif
ESP32-MINI-1
ESP32-MINI-1: https://www.espressif.com/sites/default/files/documentation/esp32-mini-1_datasheet_en.pdf
ESP32-MINI-1
0
63
55
PCM_Espressif
ESP32-MINI-1U
ESP32-MINI-1U: https://www.espressif.com/sites/default/files/documentation/esp32-mini-1_datasheet_en.pdf
ESP32-MINI-1U
0
63
55
PCM_Espressif
ESP32-PICO-MINI-02
ESP32-PICO-MINI-02: https://www.espressif.com/sites/default/files/documentation/esp32-pico-mini-02_datasheet_en.pdf
ESP32-PICO-MINI-02
0
61
53
PCM_Espressif
ESP32-PICO-MINI-02U
ESP32-PICO-MINI-02U: https://www.espressif.com/sites/default/files/documentation/esp32-pico-mini-02_datasheet_en.pdf
ESP32-PICO-MINI-02U
0
61
53
PCM_Espressif
ESP32-PICO-MINI-02_HandSoldering
ESP32-PICO-MINI-02: https://www.espressif.com/sites/default/files/documentation/esp32-pico-mini-02_datasheet_en.pdf
ESP32-PICO-MINI-02
0
61
53
PCM_Espressif
ESP32-S2-DevKitC-1
ESP32-S2 general-purpose development board, based on ESP32-S2-SOLO or ESP32-S2-SOLO-U,It has all the ESP32-S2 pins exposed and is easy to connect and use.
ESP32-S2
0
44
44
PCM_Espressif
ESP32-S2-DevKitM
ESP32-S2 general-purpose development board
ESP32-S2
0
42
42
PCM_Espressif
ESP32-S2-MINI-1
ESP32-S2-MINI-1 and ESP32-S2-MINI-1U: https://www.espressif.com/sites/default/files/documentation/esp32-s2-mini-1_esp32-s2-mini-1u_datasheet_en.pdf
ESP32-S2
0
73
65
PCM_Espressif
ESP32-S2-MINI-1U
ESP32-S2-MINI-1 and ESP32-S2-MINI-1U: https://www.espressif.com/sites/default/files/documentation/esp32-s2-mini-1_esp32-s2-mini-1u_datasheet_en.pdf
ESP32-S2
0
73
65
PCM_Espressif
ESP32-S2-MINI-1_HandSoldering
ESP32-S2-MINI-1 and ESP32-S2-MINI-1U: https://www.espressif.com/sites/default/files/documentation/esp32-s2-mini-1_esp32-s2-mini-1u_datasheet_en.pdf
ESP32-S2 Hand Soldering
0
73
65
PCM_Espressif
ESP32-S2-SOLO
ESP32-S2-SOLO https://www.espressif.com/sites/default/files/documentation/esp32-s2-solo_esp32-s2-solo-u_datasheet_en.pdf
esp32-s2 module
0
49
41
PCM_Espressif
ESP32-S2-SOLO-2U
ESP32-S2-SOLO-2U https://www.espressif.com/sites/default/files/documentation/esp32-s2-solo-2_esp32-s2-solo-2u_datasheet_en.pdf
esp32-s2 module
0
49
41
PCM_Espressif
ESP32-S2-Saola-1
Espressif ESP32-S2-Saola-1 Development Kit: https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-saola-1-v1.2.html
esp32-s2 devkit
0
42
42
PCM_Espressif
ESP32-S2-WROOM
ESP32-S2-WROOM and ESP32-S2-WROOM-I: https://www.espressif.com/sites/default/files/documentation/esp32-s2-wroom_esp32-s2-wroom-i_datasheet_en.pdf
ESP32-S2
0
51
43
PCM_Espressif
ESP32-S2-WROVER
ESP32-S2-WROVER and ESP32-S2-WROVER-I: https://www.espressif.com/sites/default/files/documentation/esp32-s2-wrover_esp32-s2-wrover-i_datasheet_en.pdf
ESP32-S2
0
55
43
PCM_Espressif
ESP32-S3-DevKitC
ESP32-S3 general-purpose development board, based on ESP32-S3-WROOM-1 or ESP32-S3-WROOM-1U,It has all the ESP32-S3 pins exposed and is easy to connect and use.
ESP32-S3
0
44
44
PCM_Espressif
ESP32-S3-MINI-1
ESP32-S3-MINI-1
esp32-s3
0
73
65
PCM_Espressif
ESP32-S3-MINI-1U
ESP32-S3-MINI-1 and ESP32-S3-MINI-1U
esp32-s3
0
73
65
PCM_Espressif
ESP32-S3-WROOM-1
ESP32-S3-WROOM-1 is a powerful, generic Wi-Fi + Bluetooth LE MCU modules that have Dual core CPU , a rich set of peripherals, provides acceleration for neural network computing and signal processing workloads. They are an ideal choice for a wide variety of application scenarios related to AI + Internet of Things (AIoT), such as wake word detection and speech commands recognition , face detection and recognition, smart home, smart appliance, smart control panel, smart speaker etc.
esp32-s3
0
51
41
PCM_Espressif
ESP32-S3-WROOM-1U
ESP32-S3-WROOM-1 is a powerful, generic Wi-Fi + Bluetooth LE MCU modules that have Dual core CPU , a rich set of peripherals, provides acceleration for neural network computing and signal processing workloads. They are an ideal choice for a wide variety of application scenarios related to AI + Internet of Things (AIoT), such as wake word detection and speech commands recognition , face detection and recognition, smart home, smart appliance, smart control panel, smart speaker etc.
esp32-s3
0
49
41
PCM_Espressif
ESP32-S3-WROOM-2
ESP32-S3-WROOM-2 is a powerful, generic Wi-Fi + Bluetooth LE MCU modules that have Dual core CPU , a rich set of peripherals, provides acceleration for neural network computing and signal processing workloads. They are an ideal choice for a wide variety of application scenarios related to AI + Internet of Things (AIoT), such as wake word detection and speech commands recognition , face detection and recognition, smart home, smart appliance, smart control panel, smart speaker etc.
esp32-s3
0
51
41
PCM_Espressif
ESP32-WROOM-32E
ESP32-WROOM-32E and ESP32-WROOM-32UE: https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32e_esp32-wroom-32ue_datasheet_en.pdf
ESP32
0
50
39
PCM_Espressif
ESP32-WROOM-32UE
ESP32-WROOM-32E and ESP32-WROOM-32UE: https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32e_esp32-wroom-32ue_datasheet_en.pdf
ESP32
0
47
39
PCM_Espressif
ESP32-WROOM-DA
ESP32-WROOM-DA: https://www.espressif.com/sites/default/files/documentation/esp32-wroom-da_datasheet_en.pdf
ESP32 Dual Antenna DA
0
49
41
PCM_Espressif
ESP32-WROVER-E
ESP32-WROVER-E: https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32e_esp32-wroom-32ue_datasheet_en.pdf
esp32 module
0
47
39
PCM_Espressif
ESP32-WROVER-E_ThermalVias
ESP32-WROVER-E: https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32e_esp32-wroom-32ue_datasheet_en.pdf
esp32 module thermal vias
0
59
39
PCM_Espressif
ESP8685-WROOM-06
ESP32-WROOM-06: https://www.espressif.com/sites/default/files/documentation/esp8685-wroom-06_datasheet_en.pdf
esp32 module
0
31
22
PCM_Espressif
QFN-32-1EP_4x4mm_P0.4mm_EP2.9x2.9mm
QFN, 32 Pin (http://ww1.microchip.com/downloads/en/DeviceDoc/atmel-8153-8-and-16-bit-avr-microcontroller-xmega-e-atxmega8e5-atxmega16e5-atxmega32e5_datasheet.pdf#page=70), generated with kicad-footprint-generator ipc_noLead_generator.py
QFN NoLead
0
37
33
Package_BGA
Alliance_TFBGA-54_8x8mm_Layout9x9_P0.8mm
Alliance TFBGA 54 pins, 8x8mm, 54 Ball, 9x9 Layout, 0.8mm Pitch, https://www.alliancememory.com/wp-content/uploads/pdf/dram/Alliance_Memory_64M-AS4C4M16SA-CI_v5.0_October_2018.pdf#page=54
@@ -83829,7 +84130,7 @@ Bottom Block Connector
0
12
16
5
Quinn_lib
Top Block Connector

View File

@@ -64,6 +64,17 @@
)
)
(attr through_hole)
(fp_rect
(start -25 -25)
(end 25 25)
(stroke
(width 0.1)
(type default)
)
(fill none)
(layer "F.SilkS")
(uuid "02d89982-2879-49da-992f-c4d987f0fd39")
)
(fp_rect
(start -9.044238 -9.06015)
(end 9.076061 9.048037)

View File

@@ -5,40 +5,45 @@
#pragma once
// Stack pins
// Stack 1 pins
#define STACK1_ADC_PIN 4
#define STACK1_LED_PIN 9
#define STACK1_ADC_PIN 6
#define STACK1_LED_PIN 11
// Stack 2 pins
#define STACK2_ADC_PIN 5
#define STACK2_LED_PIN 10
#define STACK2_ADC_PIN 16
#define STACK2_LED_PIN 14
// Stack 3 pins
#define STACK3_ADC_PIN 6
#define STACK3_LED_PIN 11
#define STACK3_ADC_PIN 8
#define STACK3_LED_PIN 45
// Stack 4 pins
#define STACK4_ADC_PIN 7
#define STACK4_LED_PIN 12
#define STACK4_ADC_PIN 5
#define STACK4_LED_PIN 10
// Stack 5 pins
#define STACK5_ADC_PIN 15
#define STACK5_LED_PIN 13
// Stack 6 pins
#define STACK6_ADC_PIN 16
#define STACK6_LED_PIN 14
#define STACK6_ADC_PIN 18
#define STACK6_LED_PIN 38
// Stack 7 pins
#define STACK7_ADC_PIN 17
#define STACK7_LED_PIN 37
#define STACK7_ADC_PIN 4
#define STACK7_LED_PIN 9
// Stack 8 pins
#define STACK8_ADC_PIN 18
#define STACK8_LED_PIN 38
#define STACK8_ADC_PIN 7
#define STACK8_LED_PIN 12
// Stack 9 pins
#define STACK9_ADC_PIN 8
#define STACK9_LED_PIN 45
#define STACK9_ADC_PIN 17
#define STACK9_LED_PIN 37
// Bluetooth module configuration pins
#define BT_STATE_PIN 2
#define BT_EN_PIN 3

View File

@@ -15,20 +15,22 @@ CubeStack::CubeStack(uint16_t ADCPin, uint16_t ledPin, uint8_t numLEDs){
uint8_t CubeStack::GetNumberCubes(){
// read the ADC and return the number of cubes
/*
0 cubes: 1 : 4095-3071
1 cube: 1/2 3070-1706
2 cubes: 1/3 1705-1195
3 cubes: 1/4 1195-0
0 cubes: 1 : 4095-3400
1 cube: 1/2 3400-2500
2 cubes: 1/3 2500-1850
3 cubes: 1/4 1850-0
*/
uint16_t value = analogRead(this->ADCPin);
this->lowPassADCRead = static_cast<uint16_t>((static_cast<float>(this->lowPassADCRead) * 0.9) + (static_cast<float>(value) * 0.1));
if(this->lowPassADCRead < 2500 && false){
Serial.println("ADC Pin:" + String(this->ADCPin) + " Value: " + String(value) + " Low Pass: " + String(this->lowPassADCRead));
}
// temporary definitions to define value ranges:
uint16_t zeroCubesHigh = 4095;
uint16_t zeroCubesLow = 3071;
uint16_t oneCubeLow = 1706;
uint16_t twoCubesLow = 1000;
uint16_t zeroCubesLow = 3400;
uint16_t oneCubeLow = 2500;
uint16_t twoCubesLow = 1850;
uint16_t threeCubesLow = 0;
uint8_t stackHeight = 0;

1
lib/SerialMessage Submodule

Submodule lib/SerialMessage added at 7cd43742b6

View File

@@ -1,58 +0,0 @@
#include "BluetoothSerialMessage.h"
BluetoothSerialMessage::BluetoothSerialMessage(BluetoothSerial *serial){
this->serial = serial;
}
void BluetoothSerialMessage::Init(unsigned int baud_rate){
// Don't need to do anything here, just let the user init bluetooth serial
}
void BluetoothSerialMessage::PrintArgs(){
serial->print("Current number of args: ");
serial->println(populated_args);
for (int i = 0; i < populated_args; i++) {
serial->print(args[i]);
serial->print(" ");
}
serial->println();
}
void BluetoothSerialMessage::readSerial(){
boolean recvInProgress = false;
byte ndx = 0;
char c;
// read the incoming serial data:
while (serial->available() > 0 && data_recieved == false) {
// get the neext character in the serial buffer
c = serial->read();
Serial.print(c);
// only execute this if the startMarker has been received
if (recvInProgress == true) {
// if the incoming character is not the endMarker...
if (c != endMarker) {
// add it to the data array
data[ndx] = c;
ndx++; // increment the data array index
// if the index is greater than the maximum data array size,
// keep overwriting the last element until the endMarker is received.
if (ndx >= num_chars) {
ndx = num_chars - 1;
}
}
// if the incoming character is the endMarker clean up and set the flags
else {
data[ndx] = '\0'; // terminate the string
recvInProgress = false;
ndx = 0;
data_recieved = true;
}
}
// if the incoming character is the startMarker, set the recvInProgress flag
else if (c == startMarker) {
recvInProgress = true;
}
}
}

View File

@@ -1,31 +0,0 @@
#pragma once
#include "SerialMessage.h"
#include <BluetoothSerial.h>
class BluetoothSerialMessage : public SerialMessage{
public:
/**
* @brief Construct a new Bluetooth Serial Message object
*/
BluetoothSerialMessage(BluetoothSerial *serial);
/**
* @brief Initialize the BluetoothSerialMessage object
*/
void Init(unsigned int baud_rate = 115200) override;
/**
* @brief prints the args array to the serial monitor
*/
void PrintArgs() override;
private:
/**
* @brief reads the serial data and stores it in the data array
*/
void readSerial() override;
BluetoothSerial *serial;
};

View File

@@ -1,111 +0,0 @@
/**
* @file SerialMessage.cpp
* @brief This file contains the SerialMessage class
* @details This file contains the SerialMessage class which is used to parse serial messages
* @version 1.0.0
* @author Quinn Henthorne. Contact: quinn.henthorne@gmail.com
*/
#include "SerialMessage.h"
SerialMessage::SerialMessage(HardwareSerial *serial) :
serial(serial){}
void SerialMessage::Init(unsigned int baud_rate){
serial->begin(baud_rate);
}
void SerialMessage::readSerial(){
char c;
// read the incoming serial data:
while (serial->available() > 0 && data_recieved == false) {
// get the neext character in the serial buffer
c = serial->read();
// only execute this if the startMarker has been received
// if the incoming character is the endMarker clean up and set the flags
if (recvInProgress == true) {
if (c == endMarker) {
data[ndx] = '\0'; // terminate the string
recvInProgress = false;
ndx = 0;
data_recieved = true;
}
// if the incoming character is not the endMarker
else {
// add it to the data array
data[ndx] = c;
ndx++; // increment the data array index
// if the index is greater than the maximum data array size,
// keep overwriting the last element until the endMarker is received.
if (ndx >= num_chars) {
ndx = num_chars - 1;
}
}
}
// if the incoming character is the startMarker, set the recvInProgress flag
else if (c == startMarker) {
recvInProgress = true;
}
}
}
void SerialMessage::parseData() { // split the data into its parts
this->populated_args = 0; // reset the populated args counter
char * indx; // this is used by strtok() as an index
int i = 0;
indx = strtok(temp_data, ","); // get the first part - the string
while(indx != NULL){
this->args[i] = atoi(indx);
populated_args++;
i++;
indx = strtok(NULL, ","); // this continues where the previous call left off
}
}
void SerialMessage::Update(){
readSerial();
if (data_recieved == true) {
// for debug only:
// Serial.print("Received:");
// Serial.print(data);
// Serial.println(":End");
strcpy(temp_data, data);
// this temporary copy is necessary to protect the original data
// because strtok() used in parseData() replaces the commas with \0
parseData();
//PrintArgs();
data_recieved = false;
new_data = true;
}
}
bool SerialMessage::IsNewData(){
return new_data;
}
void SerialMessage::ClearNewData(){
new_data = false;
}
int * SerialMessage::GetArgs(){
return args;
}
int SerialMessage::GetArgsLength(){
return args_length;
}
int SerialMessage::GetPopulatedArgs(){
return populated_args;
}
void SerialMessage::PrintArgs(){
serial->print("Current number of args: ");
serial->println(populated_args);
for (int i = 0; i < populated_args; i++) {
serial->print(args[i]);
serial->print(" ");
}
serial->println();
}

View File

@@ -1,87 +0,0 @@
/**
* @file SerialMessage.h
* @brief This file contains the SerialMessage class
* @details This file contains the SerialMessage class which is used to parse serial messages
* @version 1.0.0
* @author Quinn Henthorne. Contact: quinn.henthorne@gmail.com
*/
#ifndef SERIALMESSAGE_H
#define SERIALMESSAGE_H
#include "Arduino.h"
#define num_chars 500
class SerialMessage{
public:
/**
* @brief Construct a new Serial Message object
*/
SerialMessage(HardwareSerial *serial = &Serial);
/**
* @brief Initialize the SerialMessage object
*/
virtual void Init(unsigned int baud_rate = 115200);
/**
* @brief Update the SerialMessage object and parse any data that's available
*/
void Update();
/**
* @brief Returns true if there is new data available
* @return true if there is new data available
*/
bool IsNewData();
/**
* @brief Clears the new data flag
*/
virtual void ClearNewData();
/**
* @brief Return a pointer to the args array
* @return a pointer to the args array
*/
int * GetArgs();
/**
* @brief Returns the number of args that have been populated for the current message
* @return the number of args that have been populated for the current message
*/
int GetArgsLength();
/**
* @brief Returns the number of args that have been populated for the current message
* @return the number of args that have been populated for the current message
*/
int GetPopulatedArgs();
/**
* @brief Prints the args array to the serial monitor
*/
virtual void PrintArgs();
protected:
virtual void readSerial();
virtual void parseData();
bool new_data = false;
bool data_recieved = false;
bool recvInProgress = false;
char data[num_chars]; // an array to store the received data
char temp_data[num_chars]; // an array that will be used with strtok()
uint16_t ndx = 0;
const static int args_length = 30;
int populated_args = 0; // the number of args that have been populated for the current message
int args[args_length];
const char startMarker = '!';
const char endMarker = ';';
private:
HardwareSerial *serial;
};
#endif

View File

@@ -33,7 +33,6 @@ debug_init_break = tbreak setup
debug_tool = esp-builtin
build_type = debug
debug_speed = 20000
; upload_port = COM7
; debug_port = COM7
; monitor_port = COM14
build_flags = -O1 -Iinclude

View File

@@ -21,23 +21,44 @@ enum Commands : uint8_t{
};
// --------------------------------------------------
// ------------- OBJECT DEFINITIONS -----------------
// ----------------- VARIABLES ----------------------
// --------------------------------------------------
uint32_t boardStateTimer{0};
bool boardStateHasChanged{false};
uint32_t boardStateMaxUpdatePeriod{34}; // this is a little slower than 30fps
// BluetoothSerial SerialBT;
// BluetoothSerialMessage serialMessageBT(&SerialBT);
SerialMessage serialMessage(&Serial);
SerialMessage<500> serialMessage(&Serial);
BoardLayout board(BOARD_WIDTH, BOARD_LENGTH, BOARD_HEIGHT, stacks);
// Temporary thing until we can get bluetooth color management working on the quest
ColorManager colorManager(&board);
// --------------------------------------------------
// ----------------- VARIABLES ----------------------
// --------------------------------------------------
// --------------------------------------------------
// ----------------- FUNCTIONS ----------------------
// --------------------------------------------------
void SetupBluetoothModule(){
Serial.begin(38400);
Serial.print("AT+UART=9600,0,0\r\n"); // set baud rate to 9600
delay(100);
Serial.print("AT+NAME=blockPartyBT-v01\r\n"); // set name to blockPartyBT-v0.1
delay(100);
Serial.print("AT+PSWD=1234\r\n"); // set password to 1234
delay(100);
Serial.print("AT+ROLE=0\r\n"); // set to slave
delay(100);
// exit at mode and go into pairing mode
Serial.print("AT+INIT\r\n");
Serial.begin(9600);
delay(100);
}
void printBoardState(){
// create a buffer to hold the board state
uint16_t boardState[BOARD_WIDTH * BOARD_LENGTH];
@@ -61,9 +82,9 @@ void printBoardState(){
// SerialBT.println(";");
}
void setStackColor(int * args, int argsLength){
int stackNum = args[1];
int numColors = (argsLength - 2) / 3;
void setStackColor(uint32_t * args, int argsLength){
uint32_t stackNum = args[1];
uint32_t numColors = (argsLength - 2) / 3;
Color colors[numColors];
for(int i = 0; i < numColors; i++){
@@ -78,8 +99,8 @@ void setStackColor(int * args, int argsLength){
}
void parseData(int * args, int argsLength){
int command = args[0];
void parseData(uint32_t * args, int argsLength){
uint32_t command = args[0];
switch(command){
case Commands::BoardState:
printBoardState();
@@ -113,18 +134,29 @@ void parseData(int * args, int argsLength){
// --------------------------------------------------
// ----------------- SETUP AND LOOP -----------------
// --------------------------------------------------
void setup() {
delay(1000);
SetupBluetoothModule();
Serial.begin(9600);
// SerialBT.begin("blockPartyBT");
Color colors[] = {Color(255, 0, 0), Color(0, 0, 0), Color(0, 0, 0)};
board.SetStackColors(2, colors);
boardStateTimer = millis();
}
void loop() {
if(board.BoardStateHasChanged()){
boardStateHasChanged = true;
}
if(millis() - boardStateTimer > boardStateMaxUpdatePeriod && boardStateHasChanged){
boardStateTimer = millis();
printBoardState();
boardStateHasChanged = false;
}
// DO serial processing