Skip to content

Commit 8aa0298

Browse files
committed
xiugai battery-power
1 parent 248cd48 commit 8aa0298

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

examples/ESP32/ADC_Read_Voltage/Battery_power/Battery_power.ino

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,34 @@
2222
*/
2323
#include "Arduino.h"
2424
#include <Wire.h>
25-
#include "SSD1306.h"
25+
#include "heltec.h"
2626

27-
#define Vext 21
28-
29-
#define SDA 4 //OLED SDA pin
30-
#define SCL 15 //OLED SCL pin
31-
#define RST 16 //OLED nRST pin
27+
//#define Vext 21
28+
//
29+
//#define SDA 4 //OLED SDA pin
30+
//#define SCL 15 //OLED SCL pin
31+
//#define RST 16 //OLED nRST pin
3232
#define Fbattery 3700 //The default battery is 3700mv when the battery is fully charged.
3333

3434
float XS = 0.00225; //The returned reading is multiplied by this XS to get the battery voltage.
3535
uint16_t MUL = 1000;
3636
uint16_t MMUL = 100;
37-
SSD1306 display(0x3c, SDA, SCL, RST);
37+
//SSD1306 display(0x3c, SDA, SCL, RST);
3838

3939
void setup()
4040
{
41-
pinMode(Vext, OUTPUT);
42-
digitalWrite(Vext, LOW);
43-
delay(1000);
41+
// pinMode(Vext, OUTPUT);
42+
// digitalWrite(Vext, LOW);
43+
// delay(1000);
44+
Heltec.begin(true /*DisplayEnable Enable*/, false /*LoRa Enable*/, true /*Serial Enable*/);
4445

45-
display.init();
46-
display.flipScreenVertically();
47-
display.setFont(ArialMT_Plain_10);
48-
display.drawString(0, 0, "OLED Start");
49-
display.display();
46+
Heltec.display->init();
47+
Heltec.display->flipScreenVertically();
48+
Heltec.display->setFont(ArialMT_Plain_10);
49+
Heltec.display->drawString(0, 0, "OLED Start");
50+
Heltec.display->display();
5051
delay(1000);
51-
display.clear();
52+
Heltec.display->clear();
5253

5354
adcAttachPin(13);
5455
analogSetClockDiv(255); // 1338mS
@@ -63,15 +64,14 @@ void loop()
6364
Serial.println(analogRead(13));
6465
//Serial.println((String)d);
6566
// Serial.printf("%x",analogRead(13));
66-
display.drawString(0, 0, "Remaining battery still has:");
67-
display.drawString(0, 10, "VBAT:");
68-
display.drawString(35, 10, (String)c);
69-
display.drawString(60, 10, "(mV)");
70-
// display.drawString(90, 10, (String)d);
71-
// display.drawString(98, 10, ".";
72-
// display.drawString(107, 10, "%");
73-
display.display();
67+
Heltec.display->drawString(0, 0, "Remaining battery still has:");
68+
Heltec.display->drawString(0, 10, "VBAT:");
69+
Heltec.display->drawString(35, 10, (String)c);
70+
Heltec.display->drawString(60, 10, "(mV)");
71+
// Heltec.display->drawString(90, 10, (String)d);
72+
// Heltec.display->drawString(98, 10, ".";
73+
// Heltec.display->drawString(107, 10, "%");
74+
Heltec.display->display();
7475
delay(2000);
75-
display.clear();
76+
Heltec.display->clear();
7677
}
77-

examples/ESP32/Serial2/Serial2.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* work with ESP32's IO MUX
44
*/
55

6-
HardwareSerial Serial2(2);
6+
//HardwareSerial Serial2(2);
77

88
void setup() {
99

@@ -25,4 +25,4 @@ void loop() {
2525
int ch = Serial2.read();
2626
Serial.write(ch);
2727
}
28-
}
28+
}

0 commit comments

Comments
 (0)