Skip to content

Commit c8609ba

Browse files
committed
Redundant code removal
1 parent 97cb578 commit c8609ba

File tree

7 files changed

+3
-189
lines changed

7 files changed

+3
-189
lines changed

src/AXP2101.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -265,62 +265,27 @@ static constexpr uint8_t AW9523_REG_LEDMODE0 = 0x12;
265265
static constexpr uint8_t AW9523_REG_LEDMODE1 = 0x13;
266266

267267
void AXP2101::coreS3_init() {
268-
// AXP2101
269-
// write1Byte(0x90, 0b10110100);
270-
// write1Byte(0x99, (0b11110 - 5));
271-
// write1Byte(0x96, (0b11110 - 7));
272-
// write1Byte(0x97, (0b11110 - 2));
273268
write1Byte(0x69, 0b00110101); // AXP CHG_LED
274269
// write1Byte(0x97, (0b11110 - 2));
275270
write1Byte(0x90, 0xBF); // AXP ALDO~4,BLDO0~2,DIDO1 Enable
276271
write1Byte(0x95, 0x28); // AXP ALDO4 voltage
277272

278-
// AW9523
279-
// write1Byte(AW9523_ADDR,AW9523_REG_LEDMODE0, 0xFF);
280-
// write1Byte(AW9523_ADDR,AW9523_REG_LEDMODE1, 0xFF);
281-
// write1Byte(AW9523_ADDR,AW9523_REG_CONFIG0, 0b00011000);
282-
// write1Byte(AW9523_ADDR,AW9523_REG_CONFIG1, 0b00001100);
283-
// write1Byte(AW9523_ADDR,AW9523_REG_GCR, (1 << 4));
284-
// write1Byte(AW9523_ADDR,0x03, 0b10000011);
285-
// write1Byte(AW9523_ADDR,0x02, 0b00000101);
286273
write1Byte(AW9523_ADDR, 0x02, 0b00000101); // P0
287274
write1Byte(AW9523_ADDR, 0x03, 0b00000011);
288275
write1Byte(AW9523_ADDR, 0x04, 0b00011000);
289276
write1Byte(AW9523_ADDR, 0x05, 0b00001100);
290277
write1Byte(AW9523_ADDR, 0x11, 0b00010000);
291278
write1Byte(AW9523_ADDR, 0x12, 0b11111111);
292279
write1Byte(AW9523_ADDR, 0x13, 0b11111111);
293-
// // ALDO2 set to 3.3v
294-
// write1Byte(0x93, 28);
295-
// // ALDO1 set to 1.8v (0.5 + 100*13)
296-
// write1Byte(0x92, 12);
297-
298-
// // ALDO3 set to 3.3v
299-
// write1Byte(0x94, 28);
300-
// // ALDO4 set to 3.3v
301-
// write1Byte(0x95, 28);
302-
// write1Byte(0x69, 0b00110101);
303280
}
304281

305282
void AXP2101::coreS3_AW9523_init() {
306-
/* Copy from lovyan */
307-
// m5gfx::i2c::writeRegister8(i2c_port, AW9523_ADDR, AW9523_REG_CONFIG0,
308-
// 0b01111000); m5gfx::i2c::writeRegister8(i2c_port, AW9523_ADDR,
309-
// AW9523_REG_CONFIG1, 0b01011000); m5gfx::i2c::writeRegister8(i2c_port,
310-
// AW9523_ADDR, AW9523_REG_LEDMODE0, 0b11111110);
311-
// m5gfx::i2c::writeRegister8(i2c_port, AW9523_ADDR,
312-
// AW9523_REG_LEDMODE1, 0b11111000); m5gfx::i2c::writeRegister8(i2c_port,
313-
// AW9523_ADDR, AW9523_REG_GCR,(1 << 4));
314-
315283
write1Byte(0x58, 0x04, 0b01111000);
316284
write1Byte(0x58, 0x05, 0b01011000);
317285
write1Byte(0x58, 0x12, 0b11111110);
318286
write1Byte(0x58, 0x13, 0b11111000);
319287
write1Byte(0x58, 0x11, (1 << 4));
320288

321-
// m5gfx::i2c::writeRegister8(i2c_port, AW9523_ADDR, 0x02, 0b00000110);
322-
// m5gfx::i2c::writeRegister8(i2c_port, AW9523_ADDR, 0x03, 0b10100000);
323-
324289
/* Pull up p0_1 p0_2 */
325290
// write1Byte(0x58, 0x02, 0b00000110);
326291
/* Pull up p1_7 p1_5 */

src/M5CoreS3.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,8 @@ void M5CoreS3::begin(bool LCDEnable, bool USBSerialEnable, bool I2CEnable) {
2929
if (I2CEnable) {
3030
Wire.begin(2, 1, 100000UL);
3131
}
32-
// Btn.begin();
33-
34-
// if (LEDEnable) {
35-
// dis.begin();
36-
// }
37-
// Rtc.begin();
3832
}
3933

40-
// void M5CoreS3::update() {
41-
// Touch.update();
42-
// Buttons.update();
43-
// yield();
44-
// }
45-
4634
void M5CoreS3::shutdown() {
4735
Axp.powerOFF();
4836
}
@@ -55,21 +43,4 @@ int M5CoreS3::shutdown(int seconds) {
5543
return 0;
5644
}
5745

58-
// int M5CoreS3::shutdown(const RTC_TimeTypeDef &RTC_TimeStruct) {
59-
// Rtc.clearIRQ();
60-
// Rtc.SetAlarmIRQ(RTC_TimeStruct);
61-
// delay(10);
62-
// Axp.powerOFF();
63-
// return 0;
64-
// }
65-
66-
// int M5CoreS3::shutdown(const RTC_DateTypeDef &RTC_DateStruct,
67-
// const RTC_TimeTypeDef &RTC_TimeStruct) {
68-
// Rtc.clearIRQ();
69-
// Rtc.SetAlarmIRQ(RTC_DateStruct, RTC_TimeStruct);
70-
// delay(10);
71-
// Axp.powerOFF();
72-
// return 0;
73-
// }
74-
7546
M5CoreS3 M5;

src/M5CoreS3.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,12 @@ class M5CoreS3 {
2323
~M5CoreS3();
2424
void begin(bool LCDEnable = true, bool SerialEnable = true,
2525
bool I2CEnable = false);
26-
// void update();
2726
void shutdown();
2827
int shutdown(int seconds);
29-
// int shutdown(const RTC_TimeTypeDef &RTC_TimeStruct);
30-
// int shutdown(const RTC_DateTypeDef &RTC_DateStruct,
31-
// const RTC_TimeTypeDef &RTC_TimeStruct);
32-
3328
M5Display Lcd = M5Display();
3429

3530
I2C_IMU IMU;
3631

37-
// M5Touch Touch;
38-
39-
// M5Buttons Buttons; // Buttons (global button and gesture functions)
40-
4132
AXP2101 Axp;
4233

4334
RTC Rtc;

src/M5Display.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <FS.h>
66
#include <SPI.h>
77

8-
#include "utility/Config.h" // This is where Core2 defines would be
8+
#include "utility/Config.h"
99
#include "utility/In_eSPI.h"
1010
// #include "utility/Sprite.h"
1111
#include "Fonts/HZK16.h"

src/utility/I2C_IMU.cpp

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -203,76 +203,6 @@ void I2C_IMU::MagCalibration() {
203203
mag_data.offset.z = value_z_min + (value_z_max - value_z_min) / 2;
204204
}
205205

206-
/* bool I2C_IMU::ReadCalibration() {
207-
esp_err_t err = ESP_OK;
208-
209-
nvs_handle_t nvs_handle;
210-
size_t len;
211-
212-
err = nvs_open("storage", NVS_READONLY, &nvs_handle);
213-
if (err == ESP_OK) {
214-
len = sizeof(mag_data.offset);
215-
err = nvs_get_blob(nvs_handle, "compass", &mag_data.offset, &len);
216-
if (err != ESP_OK) {
217-
Serial.printf("Read compass calibration data failed <%s>\r\n",
218-
esp_err_to_name(err));
219-
return err == ESP_OK ? true : false;
220-
}
221-
nvs_close(nvs_handle);
222-
}
223-
return err == ESP_OK ? true : false;
224-
}
225-
226-
bool I2C_IMU::SaveCalibration() {
227-
esp_err_t err = ESP_OK;
228-
nvs_handle_t nvs_handle;
229-
230-
err = nvs_open("storage", NVS_READWRITE, &nvs_handle);
231-
if (err == ESP_OK) {
232-
err = nvs_set_blob(nvs_handle, "compass", &mag_data.offset,
233-
sizeof(mag_data.offset));
234-
if (err != ESP_OK) {
235-
Serial.printf("Set compass calibration data failed <%s>\r\n",
236-
esp_err_to_name(err));
237-
return err == ESP_OK ? true : false;
238-
}
239-
240-
err = nvs_commit(nvs_handle);
241-
if (err != ESP_OK) {
242-
Serial.printf(
243-
"Commit compass calibration data change failed <%s>\r\n",
244-
esp_err_to_name(err));
245-
return err == ESP_OK ? true : false;
246-
}
247-
nvs_close(nvs_handle);
248-
}
249-
return err == ESP_OK ? true : false;
250-
} */
251-
252-
// void read_bmi_bmm_data(struct bmi2_sens_data *accel_gyro_data,
253-
// struct bmm150_mag_data *mag_data,
254-
// struct bmm150_raw_mag_data *raw_mag_data) {
255-
// aux_bmi2_dev.delay_us(50000, aux_bmi2_dev.intf_ptr);
256-
// /* To get the data ready interrupt status of accel, gyro and aux */
257-
// rslt = bmi2_get_int_status(&int_status, &aux_bmi2_dev);
258-
// bmi2_error_codes_print_result(rslt);
259-
260-
// /* To check the data ready interrupt status and print the status for 20
261-
// * samples. */
262-
// if ((int_status & BMI2_AUX_DRDY_INT_MASK)) {
263-
// rslt = bmi2_get_sensor_data(accel_gyro_data, &aux_bmi2_dev);
264-
// bmi2_error_codes_print_result(rslt);
265-
266-
// if (rslt == BMI2_OK) {
267-
// /* To read the mag data */
268-
// rslt = bmm150_aux_raw_mag_data(sensor_data.aux_data, mag_data,
269-
// raw_mag_data, &aux_bmm150_dev);
270-
// bmm150_error_codes_print_result(rslt);
271-
// }
272-
// }
273-
// }
274-
275-
/******************************************************************************/
276206
int8_t I2C_IMU::bmi2_i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len,
277207
void *intf_ptr) {
278208
if ((reg_data == NULL) || (len == 0) || (len > 32)) {

src/utility/I2C_IMU.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,7 @@ class I2C_IMU {
4747
void Update();
4848
float CalcuDir();
4949
void MagCalibration();
50-
/* bool ReadCalibration();
51-
bool SaveCalibration();
52-
void read_bmi_bmm_data(struct bmi2_sens_data *accel_gyro_data,
53-
struct bmm150_mag_data *mag_data,
54-
struct bmm150_raw_mag_data *raw_mag_data);
55-
*/
50+
5651
private:
5752
const uint8_t BMI270_ADDR = BMI2_I2C_SEC_ADDR;
5853
const uint8_t BMM150_ADDR = BMM150_DEFAULT_I2C_ADDRESS;

src/utility/I2C_PORT.cpp

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -86,42 +86,4 @@ void I2C_PORT::write16Bit(uint8_t subAddress, uint8_t data_1, uint8_t data_2) {
8686
_wire->write(data_1);
8787
_wire->write(data_2);
8888
_wire->endTransmission();
89-
}
90-
91-
/* /**
92-
* @brief I2C device scan
93-
*
94-
* @return int I2C device number
95-
int I2C_PORT::I2C_dev_scan() {
96-
uint8_t error, address;
97-
int nDevices;
98-
99-
Serial.println("[I2C_SCAN] device scanning...");
100-
101-
nDevices = 0;
102-
for (address = 1; address < 127; address++) {
103-
// The i2c_scanner uses the return value of
104-
// the Write.endTransmisstion to see if
105-
// a device did acknowledge to the address.
106-
Wire.beginTransmission(address);
107-
error = Wire.endTransmission();
108-
109-
if (error == 0) {
110-
Serial.print("[I2C_SCAN]: device found at address 0x");
111-
if (address < 16) Serial.print("0");
112-
Serial.print(address, HEX);
113-
Serial.println(" !");
114-
115-
nDevices++;
116-
} else if (error == 4) {
117-
Serial.print("[I2C_SCAN]: unknow error at address 0x");
118-
if (address < 16) Serial.print("0");
119-
Serial.println(address, HEX);
120-
}
121-
}
122-
123-
Serial.print("[I2C_SCAN]:");
124-
Serial.printf(" %d devices was found\r\n", nDevices);
125-
return nDevices;
126-
}
127-
*/
89+
}

0 commit comments

Comments
 (0)