Added error message for VL53L0X initialization

Slightly updated the schematics
This commit is contained in:
Mark van Renswoude 2020-01-27 19:34:08 +01:00
parent 73ba3b2750
commit 344e0bd3b0
11 changed files with 769 additions and 257 deletions

47
doc/errors.md Normal file
View File

@ -0,0 +1,47 @@
# Error codes reference
During startup a number of error codes may be presented. This document serves as a reference for tracing the problem.
### height sensor
Errors are logged as "code @ position". Code is the status code as returned by the VL53L0X API, and position determines which API call during initialization failed. Test
| Code | Constant | Description |
|--|--|--|
| -1 | VL53L0X_ERROR_CALIBRATION_WARNING | Warning invalid calibration data may be in used VL53L0X_InitData(), VL53L0X_GetOffsetCalibrationData, VL53L0X_SetOffsetCalibrationData |
| -2 | VL53L0X_ERROR_MIN_CLIPPED | Warning parameter passed was clipped to min before to be applied |
| -3 | VL53L0X_ERROR_UNDEFINED | Unqualified error |
| -4 | VL53L0X_ERROR_INVALID_PARAMS | Parameter passed is invalid or out of range |
| -5 | VL53L0X_ERROR_NOT_SUPPORTED | Function is not supported in current mode or configuration |
| -6 | VL53L0X_ERROR_RANGE_ERROR | Device report a ranging error interrupt status |
| -7 | VL53L0X_ERROR_TIME_OUT | Aborted due to time out |
| -8 | VL53L0X_ERROR_MODE_NOT_SUPPORTED | Asked mode is not supported by the device |
| -9 | VL53L0X_ERROR_BUFFER_TOO_SMALL | ... |
| -10 | VL53L0X_ERROR_GPIO_NOT_EXISTING | User tried to setup a non-existing GPIO pin |
| -11 | VL53L0X_ERROR_GPIO_FUNCTIONALITY_NOT_SUPPORTED | unsupported GPIO functionality |
| -12 | VL53L0X_ERROR_INTERRUPT_NOT_CLEARED | Error during interrupt clear |
| -20 | VL53L0X_ERROR_CONTROL_INTERFACE | error reported from IO functions |
| -30 | VL53L0X_ERROR_INVALID_COMMAND | The command is not allowed in the current device state (power down) |
| -40 | VL53L0X_ERROR_DIVISION_BY_ZERO | In the function a division by zero occurs |
| -50 | VL53L0X_ERROR_REF_SPAD_INIT | Error during reference SPAD initialization |
| -99 | VL53L0X_ERROR_NOT_IMPLEMENTED |
<br>
| Position | Description |
|--|--|
| 1 | VL53L0X_DataInit |
| 2 | VL53L0X_SetDeviceAddress |
| 3 | VL53L0X_GetDeviceInfo |
| 4 | VL53L0X_StaticInit |
| 5 | VL53L0X_PerformRefSpadManagement |
| 6 | VL53L0X_PerformRefCalibration |
| 7 | VL53L0X_SetDeviceMode |
| 8 | VL53L0X_SetLimitCheckEnable(VL53L0X_CHECKENABLE_SIGMA_FINAL_RANGE) |
| 9 | VL53L0X_SetLimitCheckEnable(VL53L0X_CHECKENABLE_SIGNAL_RATE_FINAL_RANGE) |
| 10 | VL53L0X_SetLimitCheckEnable(VL53L0X_CHECKENABLE_RANGE_IGNORE_THRESHOLD) |
| 11 | VL53L0X_SetLimitCheckValue(VL53L0X_CHECKENABLE_RANGE_IGNORE_THRESHOLD) |
### timing budget
Errors are logged as an VL53L0X API code. See the table above for reference.

45
doc/pinout.md Normal file
View File

@ -0,0 +1,45 @@
## ST7789 LCD
https://learn.adafruit.com/adafruit-1-3-and-1-54-240-x-240-wide-angle-tft-lcd-displays/pinouts
| Identifier | Description | Arduino pin | ATMega328p pin |
|------------|----------------------------|-------------|----------------|
| MOSI | SPI master out - slave in | 11 | 15 - PB3 |
| SCLK | SPI clock | 13 | 17 - PB5 |
| CS | Chip select | N/C | N/C |
| RST | Reset | 9 | 13 - PB1 |
| DC | SPI data / command select | 8 | 12 - PB0 |
| BL | Backlight PWM | 7 | 11 - PD7 |
## Polulu G2 motor driver
https://www.pololu.com/product/2995
| Identifier | Description | Arduino pin | ATMega328p pin |
|------------|----------------------------|-------------|----------------|
| PWM | Motor PWM | 14 | 23 - PC0 |
| DIR | Direction | 15 | 24 - PC1 |
| SLP | Sleep (active low) | 16 | 25 - PC2 |
| CS | Current sensing | 17 | 26 - PC3 |
CS has a voltage of 50mV + 20mV per A.
## VL53L0X time-of-flight sensor
https://learn.adafruit.com/adafruit-vl53l0x-micro-lidar-distance-sensor-breakout/pinouts
| Identifier | Description | Arduino pin | ATMega328p pin |
|------------|----------------------------|-------------|----------------|
| SCL | I²C clock | 18 | 28 - PC5 |
| SDA | I²C data | 19 | 27 - PC4 |
## Buttons
| Description | Arduino pin | ATMega328p pin |
|-------------|-------------|----------------|
| Up | 3 | 1 - PD3 |
| Menu | 5 | 9 - PD5 |
| Down | 6 | 10 - PD6 |

View File

@ -1,6 +1,25 @@
EESchema-LIBRARY Version 2.4 EESchema-LIBRARY Version 2.4
#encoding utf-8 #encoding utf-8
# #
# Connector_Generic_Conn_01x02
#
DEF Connector_Generic_Conn_01x02 J 0 40 Y N 1 F N
F0 "J" 0 100 50 H V C CNN
F1 "Connector_Generic_Conn_01x02" 0 -200 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
Connector*:*_1x??_*
$ENDFPLIST
DRAW
S -50 -95 0 -105 1 1 6 N
S -50 5 0 -5 1 1 6 N
S -50 50 50 -150 1 1 10 f
X Pin_1 1 -200 0 150 R 50 50 1 1 P
X Pin_2 2 -200 -100 150 R 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Connector_Generic_Conn_01x04 # Connector_Generic_Conn_01x04
# #
DEF Connector_Generic_Conn_01x04 J 0 40 Y N 1 F N DEF Connector_Generic_Conn_01x04 J 0 40 Y N 1 F N
@ -24,6 +43,66 @@ X Pin_4 4 -200 -200 150 R 50 50 1 1 P
ENDDRAW ENDDRAW
ENDDEF ENDDEF
# #
# Connector_Generic_Conn_01x07
#
DEF Connector_Generic_Conn_01x07 J 0 40 Y N 1 F N
F0 "J" 0 400 50 H V C CNN
F1 "Connector_Generic_Conn_01x07" 0 -400 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
Connector*:*_1x??_*
$ENDFPLIST
DRAW
S -50 -295 0 -305 1 1 6 N
S -50 -195 0 -205 1 1 6 N
S -50 -95 0 -105 1 1 6 N
S -50 5 0 -5 1 1 6 N
S -50 105 0 95 1 1 6 N
S -50 205 0 195 1 1 6 N
S -50 305 0 295 1 1 6 N
S -50 350 50 -350 1 1 10 f
X Pin_1 1 -200 300 150 R 50 50 1 1 P
X Pin_2 2 -200 200 150 R 50 50 1 1 P
X Pin_3 3 -200 100 150 R 50 50 1 1 P
X Pin_4 4 -200 0 150 R 50 50 1 1 P
X Pin_5 5 -200 -100 150 R 50 50 1 1 P
X Pin_6 6 -200 -200 150 R 50 50 1 1 P
X Pin_7 7 -200 -300 150 R 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Connector_Generic_Conn_01x08
#
DEF Connector_Generic_Conn_01x08 J 0 40 Y N 1 F N
F0 "J" 0 400 50 H V C CNN
F1 "Connector_Generic_Conn_01x08" 0 -500 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
$FPLIST
Connector*:*_1x??_*
$ENDFPLIST
DRAW
S -50 -395 0 -405 1 1 6 N
S -50 -295 0 -305 1 1 6 N
S -50 -195 0 -205 1 1 6 N
S -50 -95 0 -105 1 1 6 N
S -50 5 0 -5 1 1 6 N
S -50 105 0 95 1 1 6 N
S -50 205 0 195 1 1 6 N
S -50 305 0 295 1 1 6 N
S -50 350 50 -450 1 1 10 f
X Pin_1 1 -200 300 150 R 50 50 1 1 P
X Pin_2 2 -200 200 150 R 50 50 1 1 P
X Pin_3 3 -200 100 150 R 50 50 1 1 P
X Pin_4 4 -200 0 150 R 50 50 1 1 P
X Pin_5 5 -200 -100 150 R 50 50 1 1 P
X Pin_6 6 -200 -200 150 R 50 50 1 1 P
X Pin_7 7 -200 -300 150 R 50 50 1 1 P
X Pin_8 8 -200 -400 150 R 50 50 1 1 P
ENDDRAW
ENDDEF
#
# Connector_Generic_Conn_02x03_Odd_Even # Connector_Generic_Conn_02x03_Odd_Even
# #
DEF Connector_Generic_Conn_02x03_Odd_Even J 0 40 Y N 1 F N DEF Connector_Generic_Conn_02x03_Odd_Even J 0 40 Y N 1 F N
@ -172,18 +251,34 @@ X 2 2 200 0 100 L 50 50 0 1 P
ENDDRAW ENDDRAW
ENDDEF ENDDEF
# #
# power_+5V # power_+12V
# #
DEF power_+5V #PWR 0 0 Y Y 1 F P DEF power_+12V #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -150 50 H I C CNN F0 "#PWR" 0 -150 50 H I C CNN
F1 "power_+5V" 0 140 50 H V C CNN F1 "power_+12V" 0 140 50 H V C CNN
F2 "" 0 0 50 H I C CNN F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN F3 "" 0 0 50 H I C CNN
DRAW DRAW
P 2 0 1 0 -30 50 0 100 N P 2 0 1 0 -30 50 0 100 N
P 2 0 1 0 0 0 0 100 N P 2 0 1 0 0 0 0 100 N
P 2 0 1 0 0 100 30 50 N P 2 0 1 0 0 100 30 50 N
X +5V 1 0 0 0 U 50 50 1 1 W N X +12V 1 0 0 0 U 50 50 1 1 W N
ENDDRAW
ENDDEF
#
# power_+3.3V
#
DEF power_+3.3V #PWR 0 0 Y Y 1 F P
F0 "#PWR" 0 -150 50 H I C CNN
F1 "power_+3.3V" 0 140 50 H V C CNN
F2 "" 0 0 50 H I C CNN
F3 "" 0 0 50 H I C CNN
ALIAS +3.3V
DRAW
P 2 0 1 0 -30 50 0 100 N
P 2 0 1 0 0 0 0 100 N
P 2 0 1 0 0 100 30 50 N
X +3V3 1 0 0 0 U 50 50 1 1 W N
ENDDRAW ENDDRAW
ENDDEF ENDDEF
# #

View File

@ -1,4 +1,5 @@
EESchema Schematic File Version 4 EESchema Schematic File Version 4
LIBS:DeskControl-cache
EELAYER 26 0 EELAYER 26 0
EELAYER END EELAYER END
$Descr A4 11693 8268 $Descr A4 11693 8268
@ -19,7 +20,7 @@ U 1 1 5D753A97
P 5100 3400 P 5100 3400
F 0 "U1" H 4200 2050 50 0000 C CNN F 0 "U1" H 4200 2050 50 0000 C CNN
F 1 "ATmega328-AU" H 4200 2150 50 0000 C CNN F 1 "ATmega328-AU" H 4200 2150 50 0000 C CNN
F 2 "Package_QFP:TQFP-32_7x7mm_P0.8mm" H 5100 3400 50 0001 C CIN F 2 "Housings_QFP:TQFP-32_7x7mm_Pitch0.8mm" H 5100 3400 50 0001 C CIN
F 3 "http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega328_P%20AVR%20MCU%20with%20picoPower%20Technology%20Data%20Sheet%2040001984A.pdf" H 5100 3400 50 0001 C CNN F 3 "http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega328_P%20AVR%20MCU%20with%20picoPower%20Technology%20Data%20Sheet%2040001984A.pdf" H 5100 3400 50 0001 C CNN
1 5100 3400 1 5100 3400
1 0 0 -1 1 0 0 -1
@ -29,7 +30,7 @@ L Connector_Generic:Conn_01x04 J2
U 1 1 5D753B7C U 1 1 5D753B7C
P 9400 2250 P 9400 2250
F 0 "J2" H 9479 2242 50 0000 L CNN F 0 "J2" H 9479 2242 50 0000 L CNN
F 1 "SSD1306" H 9479 2151 50 0000 L CNN F 1 "VL54L0X" H 9479 2151 50 0000 L CNN
F 2 "Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm" H 9400 2250 50 0001 C CNN F 2 "Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm" H 9400 2250 50 0001 C CNN
F 3 "~" H 9400 2250 50 0001 C CNN F 3 "~" H 9400 2250 50 0001 C CNN
1 9400 2250 1 9400 2250
@ -373,122 +374,241 @@ $EndComp
$Comp $Comp
L Switch:SW_Push SW1 L Switch:SW_Push SW1
U 1 1 5D759C24 U 1 1 5D759C24
P 6250 1600 P 9300 4900
F 0 "SW1" H 6250 1885 50 0000 C CNN F 0 "SW1" H 9300 5185 50 0000 C CNN
F 1 "SW_Push" H 6250 1794 50 0000 C CNN F 1 "SW_Push" H 9300 5094 50 0000 C CNN
F 2 "SMD-BUTTON:SW4-SMD-5.2X5.2X1.5MM" H 6250 1800 50 0001 C CNN F 2 "SMD-BUTTON:SW4-SMD-5.2X5.2X1.5MM" H 9300 5100 50 0001 C CNN
F 3 "" H 6250 1800 50 0001 C CNN F 3 "" H 9300 5100 50 0001 C CNN
1 6250 1600 1 9300 4900
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
$Comp $Comp
L Switch:SW_Push SW2 L Switch:SW_Push SW2
U 1 1 5D759CB0 U 1 1 5D759CB0
P 6250 2000 P 9300 5300
F 0 "SW2" H 6250 2285 50 0000 C CNN F 0 "SW2" H 9300 5585 50 0000 C CNN
F 1 "SW_Push" H 6250 2194 50 0000 C CNN F 1 "SW_Push" H 9300 5494 50 0000 C CNN
F 2 "SMD-BUTTON:SW4-SMD-5.2X5.2X1.5MM" H 6250 2200 50 0001 C CNN F 2 "SMD-BUTTON:SW4-SMD-5.2X5.2X1.5MM" H 9300 5500 50 0001 C CNN
F 3 "" H 6250 2200 50 0001 C CNN F 3 "" H 9300 5500 50 0001 C CNN
1 6250 2000 1 9300 5300
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
$Comp $Comp
L Switch:SW_Push SW3 L Switch:SW_Push SW3
U 1 1 5D759CF0 U 1 1 5D759CF0
P 6250 2400 P 9300 5700
F 0 "SW3" H 6250 2685 50 0000 C CNN F 0 "SW3" H 9300 5985 50 0000 C CNN
F 1 "SW_Push" H 6250 2594 50 0000 C CNN F 1 "SW_Push" H 9300 5894 50 0000 C CNN
F 2 "SMD-BUTTON:SW4-SMD-5.2X5.2X1.5MM" H 6250 2600 50 0001 C CNN F 2 "SMD-BUTTON:SW4-SMD-5.2X5.2X1.5MM" H 9300 5900 50 0001 C CNN
F 3 "" H 6250 2600 50 0001 C CNN F 3 "" H 9300 5900 50 0001 C CNN
1 6250 2400 1 9300 5700
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
Wire Wire Line
5700 2200 5800 2200
Wire Wire Line
5800 2200 5800 1600
Wire Wire Line
5800 1600 6050 1600
Wire Wire Line
5700 2300 5850 2300
Wire Wire Line
5850 2300 5850 2000
Wire Wire Line
5850 2000 6050 2000
Wire Wire Line
5700 2400 6050 2400
$Comp $Comp
L power:GND #PWR05 L power:GND #PWR05
U 1 1 5D75B49B U 1 1 5D75B49B
P 6550 2400 P 9600 5700
F 0 "#PWR05" H 6550 2150 50 0001 C CNN F 0 "#PWR05" H 9600 5450 50 0001 C CNN
F 1 "GND" H 6555 2227 50 0000 C CNN F 1 "GND" H 9605 5527 50 0000 C CNN
F 2 "" H 6550 2400 50 0001 C CNN F 2 "" H 9600 5700 50 0001 C CNN
F 3 "" H 6550 2400 50 0001 C CNN F 3 "" H 9600 5700 50 0001 C CNN
1 6550 2400 1 9600 5700
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
Wire Wire Line Wire Wire Line
6450 2400 6550 2400 9500 5700 9600 5700
Wire Wire Line Wire Wire Line
6450 2000 6550 2000 9500 5300 9600 5300
Wire Wire Line Wire Wire Line
6550 2000 6550 2400 9600 5300 9600 5700
Connection ~ 6550 2400 Connection ~ 9600 5700
Wire Wire Line Wire Wire Line
6450 1600 6550 1600 9500 4900 9600 4900
Wire Wire Line Wire Wire Line
6550 1600 6550 2000 9600 4900 9600 5300
Connection ~ 6550 2000 Connection ~ 9600 5300
NoConn ~ 5700 3100
NoConn ~ 5700 3200
NoConn ~ 5700 3300
NoConn ~ 5700 3400
NoConn ~ 5700 4100 NoConn ~ 5700 4100
NoConn ~ 5700 4200
NoConn ~ 5700 4300 NoConn ~ 5700 4300
NoConn ~ 5700 4400
NoConn ~ 5700 4500
NoConn ~ 5700 4600
$Comp $Comp
L Connector_Generic:Conn_01x04 J? L Connector_Generic:Conn_01x08 J3
U 1 1 5D7651C5 U 1 1 5D7651C5
P 6500 4000 P 9650 3850
F 0 "J?" H 6650 4050 50 0000 L CNN F 0 "J3" H 9800 3900 50 0000 L CNN
F 1 "L298" H 6580 3951 50 0000 L CNN F 1 "PoluluG2" H 9730 3801 50 0000 L CNN
F 2 "" H 6500 4000 50 0001 C CNN F 2 "Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm" H 9650 3850 50 0001 C CNN
F 3 "~" H 6500 4000 50 0001 C CNN F 3 "~" H 9650 3850 50 0001 C CNN
1 6500 4000 1 9650 3850
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
$Comp $Comp
L power:GND #PWR? L power:GND #PWR014
U 1 1 5D765563 U 1 1 5D765563
P 6150 4200 P 9000 3550
F 0 "#PWR?" H 6150 3950 50 0001 C CNN F 0 "#PWR014" H 9000 3300 50 0001 C CNN
F 1 "GND" H 6155 4027 50 0000 C CNN F 1 "GND" H 9005 3377 50 0000 C CNN
F 2 "" H 6150 4200 50 0001 C CNN F 2 "" H 9000 3550 50 0001 C CNN
F 3 "" H 6150 4200 50 0001 C CNN F 3 "" H 9000 3550 50 0001 C CNN
1 6150 4200 1 9000 3550
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
Wire Wire Line Wire Wire Line
5700 3900 6300 3900 9000 3550 9450 3550
Wire Wire Line Text GLabel 5700 2200 2 50 Input ~ 0
5700 4000 6300 4000 LCD-DC
Text GLabel 5700 2300 2 50 Input ~ 0
LCD-RST
Text GLabel 5700 4600 2 50 Input ~ 0
LCD-BL
Text GLabel 5700 3100 2 50 Input ~ 0
M-PWM
Text GLabel 5700 3200 2 50 Input ~ 0
M-DIR
Text GLabel 5700 3300 2 50 Input ~ 0
M-SLP
Text GLabel 5700 3400 2 50 Input ~ 0
M-CS
Text GLabel 5700 4200 2 50 Input ~ 0
BTN-UP
Text GLabel 5700 4400 2 50 Input ~ 0
BTN-MENU
Text GLabel 5700 4500 2 50 Input ~ 0
BTN-DOWN
Text GLabel 9100 4900 0 50 Input ~ 0
BTN-UP
Text GLabel 9100 5300 0 50 Input ~ 0
BTN-MENU
Text GLabel 9100 5700 0 50 Input ~ 0
BTN-DOWN
Text GLabel 9450 4050 0 50 Input ~ 0
M-CS
Text GLabel 9450 3850 0 50 Input ~ 0
M-SLP
Text GLabel 9450 3650 0 50 Input ~ 0
M-DIR
Text GLabel 9450 3750 0 50 Input ~ 0
M-PWM
NoConn ~ 9450 3950
NoConn ~ 9450 4150
$Comp $Comp
L power:+5V #PWR? L power:+5V #PWR0101
U 1 1 5D767927 U 1 1 5E2FA39D
P 6000 4100 P 9150 4250
F 0 "#PWR?" H 6000 3950 50 0001 C CNN F 0 "#PWR0101" H 9150 4100 50 0001 C CNN
F 1 "+5V" H 6015 4273 50 0000 C CNN F 1 "+5V" H 9165 4423 50 0000 C CNN
F 2 "" H 6000 4100 50 0001 C CNN F 2 "" H 9150 4250 50 0001 C CNN
F 3 "" H 6000 4100 50 0001 C CNN F 3 "" H 9150 4250 50 0001 C CNN
1 6000 4100 1 9150 4250
-1 0 0 1 -1 0 0 1
$EndComp $EndComp
Wire Wire Line Wire Wire Line
6000 4100 6300 4100 9450 4250 9150 4250
$Comp
L Connector_Generic:Conn_01x02 J4
U 1 1 5E2FAE20
P 9400 1600
F 0 "J4" H 9479 1592 50 0000 L CNN
F 1 "PWR" H 9479 1501 50 0000 L CNN
F 2 "Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm" H 9400 1600 50 0001 C CNN
F 3 "~" H 9400 1600 50 0001 C CNN
1 9400 1600
1 0 0 -1
$EndComp
$Comp
L power:GND #PWR0102
U 1 1 5E2FAFB3
P 9100 1700
F 0 "#PWR0102" H 9100 1450 50 0001 C CNN
F 1 "GND" H 9105 1527 50 0000 C CNN
F 2 "" H 9100 1700 50 0001 C CNN
F 3 "" H 9100 1700 50 0001 C CNN
1 9100 1700
1 0 0 -1
$EndComp
Wire Wire Line Wire Wire Line
6150 4200 6300 4200 9100 1700 9200 1700
Wire Wire Line
9200 1600 8900 1600
$Comp
L power:+12V #PWR0103
U 1 1 5E2FB825
P 8900 1600
F 0 "#PWR0103" H 8900 1450 50 0001 C CNN
F 1 "+12V" H 8915 1773 50 0000 C CNN
F 2 "" H 8900 1600 50 0001 C CNN
F 3 "" H 8900 1600 50 0001 C CNN
1 8900 1600
-1 0 0 1
$EndComp
$Comp
L power:+12V #PWR0104
U 1 1 5E2FBA44
P 1400 900
F 0 "#PWR0104" H 1400 750 50 0001 C CNN
F 1 "+12V" H 1415 1073 50 0000 C CNN
F 2 "" H 1400 900 50 0001 C CNN
F 3 "" H 1400 900 50 0001 C CNN
1 1400 900
1 0 0 -1
$EndComp
$Comp
L power:PWR_FLAG #FLG0101
U 1 1 5E2FBA8B
P 1400 900
F 0 "#FLG0101" H 1400 975 50 0001 C CNN
F 1 "PWR_FLAG" H 1400 1073 50 0000 C CNN
F 2 "" H 1400 900 50 0001 C CNN
F 3 "~" H 1400 900 50 0001 C CNN
1 1400 900
-1 0 0 1
$EndComp
NoConn ~ 5700 3900
NoConn ~ 5700 4000
NoConn ~ 5700 2400
$Comp
L Connector_Generic:Conn_01x07 J5
U 1 1 5E2FE0A5
P 7300 5400
F 0 "J5" H 7379 5392 50 0000 L CNN
F 1 "ST7789" H 7379 5301 50 0000 L CNN
F 2 "Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm" H 7300 5400 50 0001 C CNN
F 3 "~" H 7300 5400 50 0001 C CNN
1 7300 5400
1 0 0 -1
$EndComp
Text GLabel 7100 5300 0 50 Input ~ 0
SCK
Text GLabel 7100 5400 0 50 Input ~ 0
MOSI
Text GLabel 7100 5500 0 50 Input ~ 0
LCD-RST
Text GLabel 7100 5600 0 50 Input ~ 0
LCD-DC
$Comp
L power:GND #PWR013
U 1 1 5E2FE81E
P 6450 5100
F 0 "#PWR013" H 6450 4850 50 0001 C CNN
F 1 "GND" H 6455 4927 50 0000 C CNN
F 2 "" H 6450 5100 50 0001 C CNN
F 3 "" H 6450 5100 50 0001 C CNN
1 6450 5100
1 0 0 -1
$EndComp
$Comp
L power:+5V #PWR015
U 1 1 5E2FEBC9
P 6650 5200
F 0 "#PWR015" H 6650 5050 50 0001 C CNN
F 1 "+5V" H 6665 5373 50 0000 C CNN
F 2 "" H 6650 5200 50 0001 C CNN
F 3 "" H 6650 5200 50 0001 C CNN
1 6650 5200
-1 0 0 1
$EndComp
Wire Wire Line
6650 5200 7100 5200
Wire Wire Line
7100 5100 6450 5100
Text GLabel 7100 5700 0 50 Input ~ 0
LCD-BL
$EndSCHEMATC $EndSCHEMATC

View File

@ -1,4 +1,5 @@
EESchema Schematic File Version 4 EESchema Schematic File Version 4
LIBS:DeskControl-cache
EELAYER 26 0 EELAYER 26 0
EELAYER END EELAYER END
$Descr A4 11693 8268 $Descr A4 11693 8268
@ -29,7 +30,7 @@ L Connector_Generic:Conn_01x04 J2
U 1 1 5D753B7C U 1 1 5D753B7C
P 9400 2250 P 9400 2250
F 0 "J2" H 9479 2242 50 0000 L CNN F 0 "J2" H 9479 2242 50 0000 L CNN
F 1 "SSD1306" H 9479 2151 50 0000 L CNN F 1 "VL54L0X" H 9479 2151 50 0000 L CNN
F 2 "Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm" H 9400 2250 50 0001 C CNN F 2 "Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm" H 9400 2250 50 0001 C CNN
F 3 "~" H 9400 2250 50 0001 C CNN F 3 "~" H 9400 2250 50 0001 C CNN
1 9400 2250 1 9400 2250
@ -55,17 +56,6 @@ RST
Text GLabel 9650 3100 2 50 Input ~ 0 Text GLabel 9650 3100 2 50 Input ~ 0
MOSI MOSI
$Comp $Comp
L power:+5V #PWR08
U 1 1 5D753EAE
P 9750 3000
F 0 "#PWR08" H 9750 2850 50 0001 C CNN
F 1 "+5V" H 9765 3173 50 0000 C CNN
F 2 "" H 9750 3000 50 0001 C CNN
F 3 "" H 9750 3000 50 0001 C CNN
1 9750 3000
1 0 0 -1
$EndComp
$Comp
L power:GND #PWR09 L power:GND #PWR09
U 1 1 5D753EEB U 1 1 5D753EEB
P 9750 3200 P 9750 3200
@ -81,47 +71,25 @@ Wire Wire Line
Wire Wire Line Wire Wire Line
9650 3200 9750 3200 9650 3200 9750 3200
$Comp $Comp
L power:+5V #PWR04
U 1 1 5D753F2B
P 8900 2350
F 0 "#PWR04" H 8900 2200 50 0001 C CNN
F 1 "+5V" H 8915 2523 50 0000 C CNN
F 2 "" H 8900 2350 50 0001 C CNN
F 3 "" H 8900 2350 50 0001 C CNN
1 8900 2350
-1 0 0 1
$EndComp
$Comp
L power:GND #PWR06 L power:GND #PWR06
U 1 1 5D753F42 U 1 1 5D753F42
P 9100 2450 P 8800 2450
F 0 "#PWR06" H 9100 2200 50 0001 C CNN F 0 "#PWR06" H 8800 2200 50 0001 C CNN
F 1 "GND" H 9105 2277 50 0000 C CNN F 1 "GND" H 8805 2277 50 0000 C CNN
F 2 "" H 9100 2450 50 0001 C CNN F 2 "" H 8800 2450 50 0001 C CNN
F 3 "" H 9100 2450 50 0001 C CNN F 3 "" H 8800 2450 50 0001 C CNN
1 9100 2450 1 8800 2450
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
Wire Wire Line Wire Wire Line
9100 2450 9200 2450 8800 2450 9200 2450
Wire Wire Line Wire Wire Line
9200 2350 8900 2350 9200 2350 8800 2350
Text GLabel 9200 2150 0 50 Input ~ 0 Text GLabel 9200 2150 0 50 Input ~ 0
SDA SDA
Text GLabel 9200 2250 0 50 Input ~ 0 Text GLabel 9200 2250 0 50 Input ~ 0
SCL SCL
$Comp $Comp
L power:+5V #PWR01
U 1 1 5D7540FC
P 900 900
F 0 "#PWR01" H 900 750 50 0001 C CNN
F 1 "+5V" H 915 1073 50 0000 C CNN
F 2 "" H 900 900 50 0001 C CNN
F 3 "" H 900 900 50 0001 C CNN
1 900 900
1 0 0 -1
$EndComp
$Comp
L power:GND #PWR03 L power:GND #PWR03
U 1 1 5D754134 U 1 1 5D754134
P 900 1450 P 900 1450
@ -202,17 +170,6 @@ Wire Wire Line
2800 2200 3100 2200 2800 2200 3100 2200
Wire Wire Line Wire Wire Line
3900 2200 4500 2200 3900 2200 4500 2200
$Comp
L power:+5V #PWR02
U 1 1 5D754E27
P 3100 1400
F 0 "#PWR02" H 3100 1250 50 0001 C CNN
F 1 "+5V" H 3115 1573 50 0000 C CNN
F 2 "" H 3100 1400 50 0001 C CNN
F 3 "" H 3100 1400 50 0001 C CNN
1 3100 1400
1 0 0 -1
$EndComp
Connection ~ 3100 2200 Connection ~ 3100 2200
Wire Wire Line Wire Wire Line
3100 2200 3350 2200 3100 2200 3350 2200
@ -341,17 +298,6 @@ F 3 "~" H 6250 3550 50 0001 C CNN
1 6250 3550 1 6250 3550
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
$Comp
L power:+5V #PWR011
U 1 1 5D7585CC
P 6250 3400
F 0 "#PWR011" H 6250 3250 50 0001 C CNN
F 1 "+5V" H 6265 3573 50 0000 C CNN
F 2 "" H 6250 3400 50 0001 C CNN
F 3 "" H 6250 3400 50 0001 C CNN
1 6250 3400
1 0 0 -1
$EndComp
Wire Wire Line Wire Wire Line
5700 3700 6250 3700 5700 3700 6250 3700
Text GLabel 6450 3700 2 50 Input ~ 0 Text GLabel 6450 3700 2 50 Input ~ 0
@ -373,122 +319,296 @@ $EndComp
$Comp $Comp
L Switch:SW_Push SW1 L Switch:SW_Push SW1
U 1 1 5D759C24 U 1 1 5D759C24
P 6250 1600 P 9300 4900
F 0 "SW1" H 6250 1885 50 0000 C CNN F 0 "SW1" H 9300 5185 50 0000 C CNN
F 1 "SW_Push" H 6250 1794 50 0000 C CNN F 1 "SW_Push" H 9300 5094 50 0000 C CNN
F 2 "SMD-BUTTON:SW4-SMD-5.2X5.2X1.5MM" H 6250 1800 50 0001 C CNN F 2 "SMD-BUTTON:SW4-SMD-5.2X5.2X1.5MM" H 9300 5100 50 0001 C CNN
F 3 "" H 6250 1800 50 0001 C CNN F 3 "" H 9300 5100 50 0001 C CNN
1 6250 1600 1 9300 4900
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
$Comp $Comp
L Switch:SW_Push SW2 L Switch:SW_Push SW2
U 1 1 5D759CB0 U 1 1 5D759CB0
P 6250 2000 P 9300 5300
F 0 "SW2" H 6250 2285 50 0000 C CNN F 0 "SW2" H 9300 5585 50 0000 C CNN
F 1 "SW_Push" H 6250 2194 50 0000 C CNN F 1 "SW_Push" H 9300 5494 50 0000 C CNN
F 2 "SMD-BUTTON:SW4-SMD-5.2X5.2X1.5MM" H 6250 2200 50 0001 C CNN F 2 "SMD-BUTTON:SW4-SMD-5.2X5.2X1.5MM" H 9300 5500 50 0001 C CNN
F 3 "" H 6250 2200 50 0001 C CNN F 3 "" H 9300 5500 50 0001 C CNN
1 6250 2000 1 9300 5300
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
$Comp $Comp
L Switch:SW_Push SW3 L Switch:SW_Push SW3
U 1 1 5D759CF0 U 1 1 5D759CF0
P 6250 2400 P 9300 5700
F 0 "SW3" H 6250 2685 50 0000 C CNN F 0 "SW3" H 9300 5985 50 0000 C CNN
F 1 "SW_Push" H 6250 2594 50 0000 C CNN F 1 "SW_Push" H 9300 5894 50 0000 C CNN
F 2 "SMD-BUTTON:SW4-SMD-5.2X5.2X1.5MM" H 6250 2600 50 0001 C CNN F 2 "SMD-BUTTON:SW4-SMD-5.2X5.2X1.5MM" H 9300 5900 50 0001 C CNN
F 3 "" H 6250 2600 50 0001 C CNN F 3 "" H 9300 5900 50 0001 C CNN
1 6250 2400 1 9300 5700
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
Wire Wire Line
5700 2200 5800 2200
Wire Wire Line
5800 2200 5800 1600
Wire Wire Line
5800 1600 6050 1600
Wire Wire Line
5700 2300 5850 2300
Wire Wire Line
5850 2300 5850 2000
Wire Wire Line
5850 2000 6050 2000
Wire Wire Line
5700 2400 6050 2400
$Comp $Comp
L power:GND #PWR05 L power:GND #PWR05
U 1 1 5D75B49B U 1 1 5D75B49B
P 6550 2400 P 9600 5700
F 0 "#PWR05" H 6550 2150 50 0001 C CNN F 0 "#PWR05" H 9600 5450 50 0001 C CNN
F 1 "GND" H 6555 2227 50 0000 C CNN F 1 "GND" H 9605 5527 50 0000 C CNN
F 2 "" H 6550 2400 50 0001 C CNN F 2 "" H 9600 5700 50 0001 C CNN
F 3 "" H 6550 2400 50 0001 C CNN F 3 "" H 9600 5700 50 0001 C CNN
1 6550 2400 1 9600 5700
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
Wire Wire Line Wire Wire Line
6450 2400 6550 2400 9500 5700 9600 5700
Wire Wire Line Wire Wire Line
6450 2000 6550 2000 9500 5300 9600 5300
Wire Wire Line Wire Wire Line
6550 2000 6550 2400 9600 5300 9600 5700
Connection ~ 6550 2400 Connection ~ 9600 5700
Wire Wire Line Wire Wire Line
6450 1600 6550 1600 9500 4900 9600 4900
Wire Wire Line Wire Wire Line
6550 1600 6550 2000 9600 4900 9600 5300
Connection ~ 6550 2000 Connection ~ 9600 5300
NoConn ~ 5700 3100
NoConn ~ 5700 3200
NoConn ~ 5700 3300
NoConn ~ 5700 3400
NoConn ~ 5700 4100 NoConn ~ 5700 4100
NoConn ~ 5700 4200
NoConn ~ 5700 4300 NoConn ~ 5700 4300
NoConn ~ 5700 4400
NoConn ~ 5700 4500
NoConn ~ 5700 4600
$Comp $Comp
L Connector_Generic:Conn_01x04 J3 L Connector_Generic:Conn_01x08 J3
U 1 1 5D7651C5 U 1 1 5D7651C5
P 6500 4000 P 9650 3850
F 0 "J3" H 6650 4050 50 0000 L CNN F 0 "J3" H 9800 3900 50 0000 L CNN
F 1 "L298" H 6580 3951 50 0000 L CNN F 1 "PoluluG2" H 9730 3801 50 0000 L CNN
F 2 "Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm" H 6500 4000 50 0001 C CNN F 2 "Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm" H 9650 3850 50 0001 C CNN
F 3 "~" H 6500 4000 50 0001 C CNN F 3 "~" H 9650 3850 50 0001 C CNN
1 6500 4000 1 9650 3850
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
$Comp $Comp
L power:GND #PWR014 L power:GND #PWR014
U 1 1 5D765563 U 1 1 5D765563
P 6150 4200 P 9000 3550
F 0 "#PWR014" H 6150 3950 50 0001 C CNN F 0 "#PWR014" H 9000 3300 50 0001 C CNN
F 1 "GND" H 6155 4027 50 0000 C CNN F 1 "GND" H 9005 3377 50 0000 C CNN
F 2 "" H 6150 4200 50 0001 C CNN F 2 "" H 9000 3550 50 0001 C CNN
F 3 "" H 6150 4200 50 0001 C CNN F 3 "" H 9000 3550 50 0001 C CNN
1 6150 4200 1 9000 3550
1 0 0 -1 1 0 0 -1
$EndComp $EndComp
Wire Wire Line Wire Wire Line
5700 3900 6300 3900 9000 3550 9450 3550
Text GLabel 5700 2200 2 50 Input ~ 0
LCD-DC
Text GLabel 5700 2300 2 50 Input ~ 0
LCD-RST
Text GLabel 5700 4600 2 50 Input ~ 0
LCD-BL
Text GLabel 5700 3100 2 50 Input ~ 0
M-PWM
Text GLabel 5700 3200 2 50 Input ~ 0
M-DIR
Text GLabel 5700 3300 2 50 Input ~ 0
M-SLP
Text GLabel 5700 3400 2 50 Input ~ 0
M-CS
Text GLabel 5700 4200 2 50 Input ~ 0
BTN-UP
Text GLabel 5700 4400 2 50 Input ~ 0
BTN-MENU
Text GLabel 5700 4500 2 50 Input ~ 0
BTN-DOWN
Text GLabel 9100 4900 0 50 Input ~ 0
BTN-UP
Text GLabel 9100 5300 0 50 Input ~ 0
BTN-MENU
Text GLabel 9100 5700 0 50 Input ~ 0
BTN-DOWN
Text GLabel 9450 4050 0 50 Input ~ 0
M-CS
Text GLabel 9450 3850 0 50 Input ~ 0
M-SLP
Text GLabel 9450 3650 0 50 Input ~ 0
M-DIR
Text GLabel 9450 3750 0 50 Input ~ 0
M-PWM
NoConn ~ 9450 3950
NoConn ~ 9450 4150
Wire Wire Line Wire Wire Line
5700 4000 6300 4000 9450 4250 9000 4250
$Comp $Comp
L power:+5V #PWR013 L Connector_Generic:Conn_01x02 J4
U 1 1 5D767927 U 1 1 5E2FAE20
P 6000 4100 P 9400 1600
F 0 "#PWR013" H 6000 3950 50 0001 C CNN F 0 "J4" H 9479 1592 50 0000 L CNN
F 1 "+5V" H 6015 4273 50 0000 C CNN F 1 "PWR" H 9479 1501 50 0000 L CNN
F 2 "" H 6000 4100 50 0001 C CNN F 2 "Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm" H 9400 1600 50 0001 C CNN
F 3 "" H 6000 4100 50 0001 C CNN F 3 "~" H 9400 1600 50 0001 C CNN
1 6000 4100 1 9400 1600
-1 0 0 1 1 0 0 -1
$EndComp
$Comp
L power:GND #PWR0102
U 1 1 5E2FAFB3
P 9100 1700
F 0 "#PWR0102" H 9100 1450 50 0001 C CNN
F 1 "GND" H 9105 1527 50 0000 C CNN
F 2 "" H 9100 1700 50 0001 C CNN
F 3 "" H 9100 1700 50 0001 C CNN
1 9100 1700
1 0 0 -1
$EndComp $EndComp
Wire Wire Line Wire Wire Line
6000 4100 6300 4100 9100 1700 9200 1700
Wire Wire Line Wire Wire Line
6150 4200 6300 4200 9200 1600 8900 1600
$Comp
L power:+12V #PWR0103
U 1 1 5E2FB825
P 8900 1600
F 0 "#PWR0103" H 8900 1450 50 0001 C CNN
F 1 "+12V" H 8915 1773 50 0000 C CNN
F 2 "" H 8900 1600 50 0001 C CNN
F 3 "" H 8900 1600 50 0001 C CNN
1 8900 1600
-1 0 0 1
$EndComp
$Comp
L power:+12V #PWR0104
U 1 1 5E2FBA44
P 1400 900
F 0 "#PWR0104" H 1400 750 50 0001 C CNN
F 1 "+12V" H 1415 1073 50 0000 C CNN
F 2 "" H 1400 900 50 0001 C CNN
F 3 "" H 1400 900 50 0001 C CNN
1 1400 900
1 0 0 -1
$EndComp
$Comp
L power:PWR_FLAG #FLG0101
U 1 1 5E2FBA8B
P 1400 900
F 0 "#FLG0101" H 1400 975 50 0001 C CNN
F 1 "PWR_FLAG" H 1400 1073 50 0000 C CNN
F 2 "" H 1400 900 50 0001 C CNN
F 3 "~" H 1400 900 50 0001 C CNN
1 1400 900
-1 0 0 1
$EndComp
NoConn ~ 5700 3900
NoConn ~ 5700 4000
NoConn ~ 5700 2400
$Comp
L Connector_Generic:Conn_01x07 J5
U 1 1 5E2FE0A5
P 7300 5400
F 0 "J5" H 7379 5392 50 0000 L CNN
F 1 "ST7789" H 7379 5301 50 0000 L CNN
F 2 "Pin_Headers:Pin_Header_Straight_1x04_Pitch2.54mm" H 7300 5400 50 0001 C CNN
F 3 "~" H 7300 5400 50 0001 C CNN
1 7300 5400
1 0 0 -1
$EndComp
Text GLabel 7100 5300 0 50 Input ~ 0
SCK
Text GLabel 7100 5400 0 50 Input ~ 0
MOSI
Text GLabel 7100 5500 0 50 Input ~ 0
LCD-RST
Text GLabel 7100 5600 0 50 Input ~ 0
LCD-DC
$Comp
L power:GND #PWR013
U 1 1 5E2FE81E
P 6450 5100
F 0 "#PWR013" H 6450 4850 50 0001 C CNN
F 1 "GND" H 6455 4927 50 0000 C CNN
F 2 "" H 6450 5100 50 0001 C CNN
F 3 "" H 6450 5100 50 0001 C CNN
1 6450 5100
1 0 0 -1
$EndComp
Wire Wire Line
6650 5200 7100 5200
Wire Wire Line
7100 5100 6450 5100
Text GLabel 7100 5700 0 50 Input ~ 0
LCD-BL
$Comp
L power:+3.3V #PWR?
U 1 1 5E300204
P 900 900
F 0 "#PWR?" H 900 750 50 0001 C CNN
F 1 "+3.3V" H 915 1073 50 0000 C CNN
F 2 "" H 900 900 50 0001 C CNN
F 3 "" H 900 900 50 0001 C CNN
1 900 900
1 0 0 -1
$EndComp
$Comp
L power:+3.3V #PWR?
U 1 1 5E300371
P 3100 1400
F 0 "#PWR?" H 3100 1250 50 0001 C CNN
F 1 "+3.3V" H 3115 1573 50 0000 C CNN
F 2 "" H 3100 1400 50 0001 C CNN
F 3 "" H 3100 1400 50 0001 C CNN
1 3100 1400
1 0 0 -1
$EndComp
$Comp
L power:+3.3V #PWR?
U 1 1 5E30051D
P 8800 2350
F 0 "#PWR?" H 8800 2200 50 0001 C CNN
F 1 "+3.3V" H 8815 2523 50 0000 C CNN
F 2 "" H 8800 2350 50 0001 C CNN
F 3 "" H 8800 2350 50 0001 C CNN
1 8800 2350
1 0 0 -1
$EndComp
$Comp
L power:+3.3V #PWR?
U 1 1 5E3005E9
P 9750 3000
F 0 "#PWR?" H 9750 2850 50 0001 C CNN
F 1 "+3.3V" H 9765 3173 50 0000 C CNN
F 2 "" H 9750 3000 50 0001 C CNN
F 3 "" H 9750 3000 50 0001 C CNN
1 9750 3000
1 0 0 -1
$EndComp
$Comp
L power:+3.3V #PWR?
U 1 1 5E300625
P 9000 4250
F 0 "#PWR?" H 9000 4100 50 0001 C CNN
F 1 "+3.3V" H 9015 4423 50 0000 C CNN
F 2 "" H 9000 4250 50 0001 C CNN
F 3 "" H 9000 4250 50 0001 C CNN
1 9000 4250
1 0 0 -1
$EndComp
$Comp
L power:+3.3V #PWR?
U 1 1 5E301977
P 6650 5200
F 0 "#PWR?" H 6650 5050 50 0001 C CNN
F 1 "+3.3V" H 6665 5373 50 0000 C CNN
F 2 "" H 6650 5200 50 0001 C CNN
F 3 "" H 6650 5200 50 0001 C CNN
1 6650 5200
-1 0 0 1
$EndComp
$Comp
L power:+3.3V #PWR?
U 1 1 5E302F90
P 6250 3400
F 0 "#PWR?" H 6250 3250 50 0001 C CNN
F 1 "+3.3V" H 6265 3573 50 0000 C CNN
F 2 "" H 6250 3400 50 0001 C CNN
F 3 "" H 6250 3400 50 0001 C CNN
1 6250 3400
1 0 0 -1
$EndComp
$EndSCHEMATC $EndSCHEMATC

View File

@ -8,19 +8,33 @@
; Please visit documentation for the other options and examples ; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html ; http://docs.platformio.org/page/projectconf.html
[platformio]
default_envs = uno
[env]
lib_deps =
Bounce2
Adafruit GFX Library
Adafruit ST7735 and ST7789 Library
Adafruit_VL53L0X
[env:uno]
platform = atmelavr
board = atmega328p
board_build.f_cpu = 16000000L
framework = arduino
upload_port = COM3
[env:atmega328] [env:atmega328]
platform = atmelavr platform = atmelavr
board = pro8MHzatmega328 board = pro8MHzatmega328
board_build.f_cpu = 8000000L
framework = arduino framework = arduino
upload_protocol = usbtiny upload_protocol = usbtiny
upload_flags = -e upload_flags = -e
upload_speed = 19200 upload_speed = 19200
board_build.f_cpu = 8000000L
lib_deps =
Bounce2
Adafruit GFX Library
Adafruit ST7735 and ST7789 Library
Adafruit_VL53L0X

View File

@ -10,5 +10,6 @@
#define DISPLAY_PORT_CS 10 #define DISPLAY_PORT_CS 10
#define DISPLAY_PORT_RST 9 #define DISPLAY_PORT_RST 9
#define DISPLAY_PORT_DC 8 #define DISPLAY_PORT_DC 8
#define DISPLAY_PORT_BL 7
#endif #endif

17
src/lib/debug.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef __debug
#define __debug
#define SerialDebug
#ifdef SerialDebug
#define DebugInit() Serial.begin(9600)
#define DebugLog(...) Serial.println(__VA_ARGS__)
#else
#define DebugInit()
#define DebugLog(...)
#endif
#endif

View File

@ -16,14 +16,27 @@ bool checkResult(VL53L0X_Error error, VL53L0XResult* result, VL53L0XPosition pos
bool VL53L0X::init(uint8_t address, VL53L0XResult* result) bool VL53L0X::init(uint8_t address, VL53L0XResult* result)
{ {
device.I2cDevAddr = address; device.I2cDevAddr = 0x29;
device.comms_type = 1; device.comms_type = 1;
device.comms_speed_khz = 400; device.comms_speed_khz = 400;
device.i2c = &Wire; device.i2c = &Wire;
if (!checkResult(VL53L0X_DataInit(&device), result, VL53L0X_POSITION_DATAINIT)) if (!checkResult(VL53L0X_DataInit(&device), result, VL53L0X_POSITION_DATAINIT))
return false; return false;
//checkResult(VL53L0X_GetDeviceInfo(&device, &deviceInfo)), result, VL53L0X_POSITION_);
auto setAddress = address & 0x7F;
// * 2 to convert from 7 to 8 bits
if (!checkResult(VL53L0X_SetDeviceAddress(&device, setAddress * 2), result, VL53L0X_POSITION_SETDEVICEADDRESS))
return false;
delay(10);
device.I2cDevAddr = setAddress;
VL53L0X_DeviceInfo_t deviceInfo;
if (!checkResult(VL53L0X_GetDeviceInfo(&device, &deviceInfo), result, VL53L0X_POSITION_GETDEVICEINFO))
return false;
if (!checkResult(VL53L0X_StaticInit(&device), result, VL53L0X_POSITION_STATICINIT)) if (!checkResult(VL53L0X_StaticInit(&device), result, VL53L0X_POSITION_STATICINIT))
return false; return false;

View File

@ -27,14 +27,16 @@ typedef struct
// Positions for the init method // Positions for the init method
#define VL53L0X_POSITION_DATAINIT ((VL53L0XPosition) 1) #define VL53L0X_POSITION_DATAINIT ((VL53L0XPosition) 1)
#define VL53L0X_POSITION_STATICINIT ((VL53L0XPosition) 2) #define VL53L0X_POSITION_SETDEVICEADDRESS ((VL53L0XPosition) 2)
#define VL53L0X_POSITION_REFSPAD ((VL53L0XPosition) 3) #define VL53L0X_POSITION_GETDEVICEINFO ((VL53L0XPosition) 3)
#define VL53L0X_POSITION_REFCAL ((VL53L0XPosition) 4) #define VL53L0X_POSITION_STATICINIT ((VL53L0XPosition) 4)
#define VL53L0X_POSITION_DEVICEMODE ((VL53L0XPosition) 5) #define VL53L0X_POSITION_REFSPAD ((VL53L0XPosition) 5)
#define VL53L0X_POSITION_LIMITRANGE ((VL53L0XPosition) 6) #define VL53L0X_POSITION_REFCAL ((VL53L0XPosition) 6)
#define VL53L0X_POSITION_LIMITRATE ((VL53L0XPosition) 7) #define VL53L0X_POSITION_DEVICEMODE ((VL53L0XPosition) 7)
#define VL53L0X_POSITION_TRESHOLD1 ((VL53L0XPosition) 8) #define VL53L0X_POSITION_LIMITRANGE ((VL53L0XPosition) 8)
#define VL53L0X_POSITION_TRESHOLD2 ((VL53L0XPosition) 9) #define VL53L0X_POSITION_LIMITRATE ((VL53L0XPosition) 9)
#define VL53L0X_POSITION_TRESHOLD1 ((VL53L0XPosition) 10)
#define VL53L0X_POSITION_TRESHOLD2 ((VL53L0XPosition) 11)
class VL53L0X class VL53L0X
{ {

View File

@ -6,6 +6,7 @@
#include "./include/display.h" #include "./include/display.h"
#include "./include/heightsensor.h" #include "./include/heightsensor.h"
#include "./include/colors.h" #include "./include/colors.h"
#include "./lib/debug.h"
#include "./lib/persist.h" #include "./lib/persist.h"
#include "./lib/menu.h" #include "./lib/menu.h"
#include "./lib/vl53l0x.h" #include "./lib/vl53l0x.h"
@ -20,7 +21,7 @@ void initSequenceError(uint8_t which, const char* message);
#define INITSEQ_HEIGHTSENSORINIT 1 #define INITSEQ_HEIGHTSENSORINIT 1
#define INITSEQ_HEIGHTSENSORBUDGET 2 #define INITSEQ_HEIGHTSENSORBUDGET 2
#define INITSEQ_HEIGHTSENSORTEST 3 #define INITSEQ_HEIGHTSENSORTEST 3
#define INITSEQ_MAX INITSEQ_HEIGHTSENSORINIT #define INITSEQ_MAX INITSEQ_HEIGHTSENSORTEST
@ -34,6 +35,11 @@ auto menu = Menu(&display);
void setup() void setup()
{ {
DebugInit();
pinMode(DISPLAY_PORT_BL, OUTPUT);
digitalWrite(DISPLAY_PORT_BL, HIGH);
display.init(DISPLAY_WIDTH, DISPLAY_HEIGHT, SPI_MODE3); display.init(DISPLAY_WIDTH, DISPLAY_HEIGHT, SPI_MODE3);
display.setRotation(DISPLAY_ROTATION); display.setRotation(DISPLAY_ROTATION);
@ -52,7 +58,28 @@ void setup()
VL53L0XResult result; VL53L0XResult result;
if (!heightSensor.init(HEIGHTSENSOR_I2C_ADDRESS, &result)) if (!heightSensor.init(HEIGHTSENSOR_I2C_ADDRESS, &result))
{ {
initSequenceError(INITSEQ_HEIGHTSENSORINIT, "TODO: error message"); char message[16] = "";
char* messagePtr = &message[0];
memset(messagePtr, 0, sizeof(message));
itoa(result.error, messagePtr, 10);
messagePtr += strlen(messagePtr);
*messagePtr = ' '; messagePtr++;
*messagePtr = '@'; messagePtr++;
*messagePtr = ' '; messagePtr++;
itoa(result.position, messagePtr, 10);
initSequenceError(INITSEQ_HEIGHTSENSORINIT, &message[0]);
/*
delay(1000);
display.sendCommand(ST77XX_SLPIN);
// toggle backlight pin
*/
while(1); while(1);
} }
initSequenceSuccess(INITSEQ_HEIGHTSENSORINIT); initSequenceSuccess(INITSEQ_HEIGHTSENSORINIT);
@ -92,36 +119,47 @@ void loop()
Helper functions for the status display during the initialization sequence Helper functions for the status display during the initialization sequence
*/ */
// Default font is 5x7, x2 for the current text size #define initSequenceTextSize 2
#define initSequenceTextY(which) ((1 + which) * 14)
// Default font is 5x7
#define initSequenceTextY(which) ((1 + which) * ((7 + 3) * initSequenceTextSize))
void initSequenceStart() void initSequenceStart()
{ {
display.fillScreen(COLOR_INITSEQ_BACKGROUND); display.fillScreen(COLOR_INITSEQ_BACKGROUND);
display.setTextSize(2); display.setTextSize(initSequenceTextSize);
display.setCursor(0, 0); display.setCursor(0, 0);
display.setTextColor(COLOR_INITSEQ_TITLE); display.setTextColor(COLOR_INITSEQ_TITLE);
display.println("Initializing..."); display.println("Initializing...");
display.setTextColor(COLOR_INITSEQ_ITEMS); display.setTextColor(COLOR_INITSEQ_ITEMS);
display.println(" reading EEPROM");
display.println(" height sensor init"); display.setCursor(0, initSequenceTextY(0));
display.println(" height sensor budget"); display.print(" reading EEPROM");
display.println(" height sensor test");
display.setCursor(0, initSequenceTextY(1));
display.print(" height sensor");
display.setCursor(0, initSequenceTextY(2));
display.print(" timing budget");
display.setCursor(0, initSequenceTextY(3));
display.print(" sensor test");
} }
void initSequenceSuccess(uint8_t which) void initSequenceSuccess(uint8_t which)
{ {
display.drawChar(0, initSequenceTextY(which), 'v', COLOR_INITSEQ_SUCCESS, GREEN, 2); display.drawChar(0, initSequenceTextY(which), 'v', COLOR_INITSEQ_SUCCESS, GREEN, initSequenceTextSize);
} }
void initSequenceError(uint8_t which, const char* message) void initSequenceError(uint8_t which, const char* message)
{ {
display.drawChar(0, initSequenceTextY(which), 'x', COLOR_INITSEQ_ERROR, COLOR_INITSEQ_ERROR, 2); display.drawChar(0, initSequenceTextY(which), 'x', COLOR_INITSEQ_ERROR, COLOR_INITSEQ_ERROR, initSequenceTextSize);
display.setCursor(0, initSequenceTextY(INITSEQ_MAX + 2)); display.setCursor(0, initSequenceTextY(INITSEQ_MAX + 2));
display.print(message); display.print(message);