|
本帖最后由 gb111111 于 2021-3-25 15:16 编辑
软件小白问个问题呢,我跟着人家的资料制作一个电子秤(ESP32+HX711),资料只有一个.ino文件,废了九牛二虎之力才把ESP32开发板弄好,现在编译出错,提示见图
百度翻译错误信息,提示说是“DSEG14_Classic_Bold_36"未定义,于是上github找到了这个DSEG14的字库安装在电脑上,结果还是不行,发帖问下会编程的坛友们,这个字库文件是要怎么处理才能编译进去呢?谢谢增加编辑:1、修改错别字;
2、刚刚试了一下,把那句注释掉以后可以编译通过;
3、另外问下这个程序可不可以直接移植到arduino nano上呢?
- * Loadcell messures - .9 lcd output - esptouch
- *
- */
- //#include <ESP8266WiFi.h> // No wifi yet? webapi for current weight?
- //#include <Wire.h> // Only needed for Arduino 1.6.5 and earlier
- #include "SSD1306Wire.h"
- #include <HX711.h>
- // Initialize the OLED display using Wire library
- SSD1306Wire display(0x3c, 21, 22); // OLED wired to 21 and 22
- HX711 scale;
- volatile bool tare_me = false;
- // touch
- const int touch_threeshold = 30; // 30 worked well with my screws, adjust here if needed
- volatile unsigned long sinceLastTouch = 0;
- // smoothing of weight, less jumpy
- float alpha = .6;
- float smooth_weight = 0;
- // offsets // ofsets set by screw touches
- volatile float offset = 0;
- const float offset_1 = 234; // esun ABS+ spools
- const float offset_2 = 420; // my custom 3kg spools
- ////////////////////////////////////////////////////////
- //
- ////////////////////////////////////////////////////////
- int digits(int in_) {
- String in_to_str = String(in_);
- int out_ = 5 - in_to_str.length();
-
- return out_;
- }
- void gotTouch1(){
- if (millis() - sinceLastTouch < 500) return;
- sinceLastTouch = millis();
-
- Serial.println("Button_1 pressed");
- delay(100);
- offset = 0;
- tare_me = true;
- }
- void gotTouch2(){
- if (millis() - sinceLastTouch < 500) return;
- sinceLastTouch = millis();
-
- Serial.println("Button_2 pressed");
- delay(100);
- offset = offset_1;
- }
- void gotTouch3(){
- if (millis() - sinceLastTouch < 500) return;
- sinceLastTouch = millis();
-
- Serial.println("Button_3 pressed");
- delay(100);
- offset = offset_2;
- }
- //
- void setup() {
- Serial.begin(115200);
- display.init();
- display.flipScreenVertically();
- touchAttachInterrupt(T0, gotTouch1, touch_threeshold);
- touchAttachInterrupt(T3, gotTouch2, touch_threeshold);
- touchAttachInterrupt(T5, gotTouch3, touch_threeshold);
-
- scale.begin(19, 23);
- delay(250);
- scale.set_scale(132.f); // this value is obtained by calibrating the scale with known weights; see the README for details
- delay(250);
- scale.tare();
- }
- void loop() {
- if(tare_me){
- display.clear();
- display.display();
- tare_me = false;
- scale.tare();
- }
- smooth_weight = alpha * scale.get_units(4) + (1-alpha) * smooth_weight;
- disp_out(smooth_weight-offset);
- }
- void disp_out(int weight) {
- display.clear();
- // tare? esun? bigspools?
- display.setFont(ArialMT_Plain_16);
- if( offset == offset_1 ){
- display.drawString(40, 0, "Offset 1");
- } else if ( offset == offset_2 ) {
- display.drawString(75, 0, "Offset 2");
- } else {
- display.drawString(0, 0, "Tara");
- }
- // weight display
- int d_ = digits(weight);
- display.setFont(DSEG14_Classic_Bold_36);
- display.drawString(d_*12, 22, (String)weight);
-
- display.display();
- }
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
|