MatrixMiniR4 1.1.9
Matrix Mini R4 Arduino Library API Documentation
Loading...
Searching...
No Matches
MatrixMiniR4.cpp
Go to the documentation of this file.
1
15#include "MatrixMiniR4.h"
16#include "Modules/MMLower.h"
17
19
29
31{
32 MMLower::RESULT result = mmL.Init();
33
34 LED.begin(7);
35 LED.setColor(1, 0, 0, 0);
36 LED.setColor(2, 0, 0, 0);
37 Buzzer.begin(6);
38
39 Motion.begin();
40
41 while (!M1.begin());
42 while (!M2.begin());
43 while (!M3.begin());
44 while (!M4.begin());
45
46 RC1.begin();
47 RC2.begin();
48 RC3.begin();
49 RC4.begin();
50
51 OLED = Adafruit_SSD1306(128, 32, &Wire1, -1);
53 OLED.setTextColor(SSD1306_WHITE); //Default Color White
54 OLED.clearDisplay();
55 OLED.display();
56
57 /* CLK: D3R(11) , CMD: D2R(4) , SET: D3L(12) , DAT: D2L(5) */
58 PS2.config_gamepad(11, 4, 12, 5, false, false);
59
60 //Check the Init is ok or not.
61 if (result != MMLower::RESULT::OK) {
62 OLED.setCursor(4, 8);
63 OLED.setTextSize(2);
64 OLED.print(F("Init Error"));
65 OLED.display();
66
67 while (true) {
68 for (uint8_t i = 0; i < 3; i++) {
69 Buzzer.Tone(700, 100);
70 delay(100);
71 Buzzer.NoTone();
72 delay(100);
73 }
74 delay(3000);
75 }
76 }
77
78 delay(200);
79 //Check the FW version is outdated or not.
80 String FWVersion_S;
81 MMLower::RESULT resultFWCheck = mmL.GetFWVersion(FWVersion_S);
82 if (resultFWCheck == MMLower::RESULT::OK) {
83 uint8_t FWmajorVersion, FWminorVersion;
84 uint8_t FWVersion_dotIndex = FWVersion_S.indexOf('.');
85 if (FWVersion_dotIndex != -1) {
86 FWmajorVersion = FWVersion_S.substring(0, FWVersion_dotIndex).toInt();
87 FWminorVersion = FWVersion_S.substring(FWVersion_dotIndex + 1).toInt();
88 if (FWmajorVersion < 6 || (FWmajorVersion == 6 && FWminorVersion < 0)) {
89 for (uint8_t i = 0; i < 3; i++) {
90 Buzzer.Tone(550, 100);
91 delay(60);
92 Buzzer.NoTone();
93 delay(60);
94 }
95
96 unsigned long lastUpdate = millis();
97 bool showFirst = true;
98 OLED.clearDisplay();
99 OLED.setTextSize(1);
100 while (BTN_DOWN.getState() == false) {
101 if (millis() - lastUpdate >= 3000) {
102 lastUpdate = millis();
103 showFirst = !showFirst;
104 }
105 OLED.clearDisplay();
106 if (showFirst) {
107 OLED.setCursor(11, 5);
108 OLED.print(F("Firmware Outdated!"));
109 OLED.setCursor(11, 18);
110 OLED.print(F(" Required: v6.0+ "));
111 } else {
112 OLED.setCursor(11, 5);
113 OLED.print(F(" Open MATRIXblock "));
114 OLED.setCursor(6, 18);
115 OLED.print(F("File->FirmwareUpdate"));
116 }
117 OLED.display();
118 delay(1);
119 }
120 OLED.clearDisplay();
121 OLED.display();
122 }
123 }
124 }
125
126 return true;
127}
128
MMLower mmL(8, 9, 57600)
Handling the Lower MCU (STM32) communication.
MatrixMiniR4 MiniR4
The MiniR4 Main Object.
Header file for the MatrixMiniR4 system, integrating various hardware modules such as motors,...
#define MATRIXMINIR4_OLED_ADDRESS
#define SSD1306_WHITE
Draw 'on' pixels.
Definition MiniR4OLED.h:102
#define SSD1306_SWITCHCAPVCC
Gen. display voltage from 3.3V.
Definition MiniR4OLED.h:131
Class that stores state and functions for interacting with SSD1306 OLED displays.
Definition MiniR4OLED.h:160
Main class for the MatrixMiniR4 system.
MiniR4RC< 3 > RC3
Port RC3 RC 5V Servo.
MiniR4DC< 1 > M1
Port M1 DC 5V Motor.
MiniR4RC< 4 > RC4
Port RC4 RC 5V Servo.
PS2X PS2
MJ2 or PS2 (4p DAT CMD to D2, 2p CS CLK to D3)
MiniR4DC< 2 > M2
Port M2 DC 5V Motor.
MiniR4LED LED
Built-in RGB LED.
MiniR4RC< 2 > RC2
Port RC2 RC 5V Servo.
MiniR4DC< 4 > M4
Port M4 DC 5V Motor.
MiniR4Motion Motion
Built-in 6-axis motion sensor.
Adafruit_SSD1306 OLED
Built-in OLED.
bool begin()
Initialize the MatrixMiniR4 system and its components.
MiniR4DC< 3 > M3
Port M3 DC 5V Motor.
MiniR4BTN< 1 > BTN_DOWN
Down Button.
MiniR4RC< 1 > RC1
Port RC1 RC 5V Servo.
MiniR4BUZZER Buzzer
Built-in Buzzer.