数码之家

 找回密码
 立即注册

QQ登录

只需一步,快速开始

微信登录

微信扫一扫,快速登录

搜索
查看: 3178|回复: 4

[other] 小白问下arduino IDE字库问题

[复制链接]
发表于 2021-3-25 14:21:44 | 显示全部楼层 |阅读模式
本帖最后由 gb111111 于 2021-3-25 15:16 编辑

软件小白问个问题呢,我跟着人家的资料制作一个电子秤(ESP32+HX711),资料只有一个.ino文件,废了九牛二虎之力才把ESP32开发板弄好,现在编译出错,提示见图

百度翻译错误信息,提示说是“DSEG14_Classic_Bold_36"未定义,于是上github找到了这个DSEG14的字库安装在电脑上,结果还是不行,发帖问下会编程的坛友们,这个字库文件是要怎么处理才能编译进去呢?谢谢增加编辑:1、修改错别字;
                2、刚刚试了一下,把那句注释掉以后可以编译通过;
                3、另外问下这个程序可不可以直接移植到arduino nano上呢?
  1. * Loadcell messures - .9 lcd output - esptouch
  2. *
  3. */

  4. //#include <ESP8266WiFi.h> // No wifi yet? webapi for current weight?
  5. //#include <Wire.h>  // Only needed for Arduino 1.6.5 and earlier
  6. #include "SSD1306Wire.h"
  7. #include <HX711.h>

  8. // Initialize the OLED display using Wire library
  9. SSD1306Wire  display(0x3c, 21, 22);                         //  OLED wired to 21 and 22
  10. HX711 scale;
  11. volatile bool tare_me = false;

  12. //  touch
  13. const int touch_threeshold = 30;                            //  30 worked well with my screws, adjust here if needed
  14. volatile unsigned long sinceLastTouch = 0;

  15. //  smoothing of weight, less jumpy
  16. float alpha = .6;
  17. float smooth_weight = 0;

  18. //  offsets                                                 //  ofsets set by screw touches
  19. volatile float offset = 0;
  20. const float offset_1 = 234;                                 //  esun ABS+ spools
  21. const float offset_2 = 420;                                 //  my custom 3kg spools

  22. ////////////////////////////////////////////////////////
  23. //
  24. ////////////////////////////////////////////////////////

  25. int digits(int in_) {

  26.   String in_to_str = String(in_);
  27.   int out_ = 5 - in_to_str.length();
  28.   
  29.   return out_;
  30. }

  31. void gotTouch1(){
  32.   if (millis() - sinceLastTouch < 500) return;
  33.   sinceLastTouch = millis();
  34.   
  35.   Serial.println("Button_1 pressed");
  36.   delay(100);
  37.   offset = 0;
  38.   tare_me = true;
  39. }

  40. void gotTouch2(){
  41.   if (millis() - sinceLastTouch < 500) return;
  42.   sinceLastTouch = millis();
  43.   
  44.   Serial.println("Button_2 pressed");
  45.   delay(100);
  46.   offset = offset_1;
  47. }

  48. void gotTouch3(){
  49.   if (millis() - sinceLastTouch < 500) return;
  50.   sinceLastTouch = millis();
  51.   
  52.   Serial.println("Button_3 pressed");
  53.   delay(100);
  54.   offset = offset_2;
  55. }

  56. //
  57. void setup() {

  58.   Serial.begin(115200);

  59.   display.init();
  60.   display.flipScreenVertically();

  61.   touchAttachInterrupt(T0, gotTouch1, touch_threeshold);
  62.   touchAttachInterrupt(T3, gotTouch2, touch_threeshold);
  63.   touchAttachInterrupt(T5, gotTouch3, touch_threeshold);
  64.   
  65.   scale.begin(19, 23);
  66.   delay(250);
  67.   scale.set_scale(132.f); // this value is obtained by calibrating the scale with known weights; see the README for details
  68.   delay(250);
  69.   scale.tare();
  70. }

  71. void loop() {

  72.   if(tare_me){
  73.     display.clear();
  74.     display.display();
  75.     tare_me = false;
  76.     scale.tare();
  77.   }

  78.   smooth_weight = alpha * scale.get_units(4) + (1-alpha) * smooth_weight;
  79.   disp_out(smooth_weight-offset);

  80. }

  81. void disp_out(int weight) {
  82.   display.clear();

  83.   //  tare? esun? bigspools?
  84.   display.setFont(ArialMT_Plain_16);
  85.   if( offset == offset_1 ){
  86.     display.drawString(40, 0, "Offset 1");
  87.   } else if ( offset == offset_2 ) {
  88.     display.drawString(75, 0, "Offset 2");
  89.   } else {
  90.     display.drawString(0, 0, "Tara");
  91.   }

  92.   //  weight display
  93.   int d_ = digits(weight);
  94.   display.setFont(DSEG14_Classic_Bold_36);
  95.   display.drawString(d_*12, 22, (String)weight);
  96.   
  97.   display.display();
  98. }
复制代码





本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册 微信登录

x
 楼主| 发表于 2021-3-26 14:41:50 | 显示全部楼层
devcang 发表于 2021-3-26 09:36
看引用的头文件,都没有和这字体相关的

就是说需要把那个字体转换成arduino能用的,然后再在头文件里面引用吗?百度半天貌似没有转换的工具啊,手工弄我也不会:sweat:能不能换成其他的字体呢?谢谢回答
回复 支持 反对

使用道具 举报

 楼主| 发表于 2021-3-30 10:34:01 | 显示全部楼层
kindzhon 发表于 2021-3-29 22:46
你的程序在哪抄的?头文件没抄?这个可能是u8g2字库,要加它的头文件。

github,他是arduino ide的ino文件,这个不能出错吧
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 微信登录

本版积分规则

APP|手机版|小黑屋|关于我们|联系我们|法律条款|技术知识分享平台

闽公网安备35020502000485号

闽ICP备2021002735号-2

GMT+8, 2025-7-18 10:02 , Processed in 0.234001 second(s), 13 queries , Redis On.

Powered by Discuz!

© 2006-2025 MyDigit.Net

快速回复 返回顶部 返回列表