1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#include <Arduino.h>
#include <USB.h>
#include <USBHIDKeyboard.h>
#include "BleMouse.h"
#include <BLEDevice.h>
#include <BLEScan.h>
#include <RF24.h>
#include <nRF24L01.h>
#include "ELECHOUSE_CC1101_SRC_DRV.h"
#include <WiFi.h>
#include <esp_wifi.h>
#include <SPI.h>
#include <esp_chip_info.h>
#include <esp_heap_caps.h>
#include <esp_system.h>
#include "ui/display.h"
#include "ui/menu.h"
#include "utils/buttons.h"
#include "config.h"
#include "rf/cc1101.h"
// ================= USB HID =================
USBHIDKeyboard Keyboard;
// ===== BLE MOUSE =====
BleMouse bleMouse("Orion-RF", "Orion-RF", 100);
RF24 radio1(CE1_PIN, CSN1_PIN);
RF24 radio2(CE2_PIN, CSN2_PIN);
SPIClass *RADIO_SPI;
void deactivateNRF1() {
digitalWrite(CSN1_PIN, HIGH);
digitalWrite(CE1_PIN, LOW);
}
void deactivateNRF2() {
digitalWrite(CSN2_PIN, HIGH);
digitalWrite(CE2_PIN, LOW);
}
// ================= SYSTEM INFO =================
void printSystemUsage() {
esp_chip_info_t chip_info;
esp_chip_info(&chip_info);
Serial.printf("CPU cores: %d\n", chip_info.cores);
Serial.printf("Free heap: %d bytes\n",
heap_caps_get_free_size(MALLOC_CAP_DEFAULT));
Serial.printf("PSRAM free: %d bytes\n",
heap_caps_get_free_size(MALLOC_CAP_SPIRAM));
}
void showSplash() {
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_logisoso20_tr); // big font
u8g2.drawStr(10, 40, "Orion-RF");
u8g2.setFont(u8g2_font_5x8_tr); // small subtitle
u8g2.drawStr(25, 58, "Initializing...");
u8g2.sendBuffer();
delay(1500); // 1.5 sec
}
// ================= SETUP =================
void setup() {
Serial.begin(115200);
displayInit();
showSplash();
buttonsInit();
menuInit();
delay(1500);
USB.begin();
Keyboard.begin();
// NRF SPI safety
// pinMode(CSN1_PIN, OUTPUT);
// digitalWrite(CSN1_PIN, HIGH);
// pinMode(CSN2_PIN, OUTPUT);
// digitalWrite(CSN2_PIN, HIGH);
deactivateNRF1();
deactivateNRF2();
RADIO_SPI = new SPIClass(FSPI);
RADIO_SPI->begin(NRF_SCK, NRF_MISO, NRF_MOSI);
// ===== CC1101 SPI INIT =====
// SPI.begin(
// cc1101_SCK,
// cc1101_MISO,
// cc1101_MOSI,
// CC1101_CS
//);
// pinMode(CC1101_CS, OUTPUT);
// pinMode(CC1101_2_CS, OUTPUT);
// digitalWrite(CC1101_CS, HIGH);
// digitalWrite(CC1101_2_CS, HIGH);
printSystemUsage();
Serial.println("SYSTEM READY");
}
// ================= LOOP =================
void loop() { menuLoop(); }
|