Skip to content

Commit 4a9d848

Browse files
committed
Fix ambiguous call of overloaded begin()
1 parent a8b6757 commit 4a9d848

File tree

4 files changed

+60
-4
lines changed

4 files changed

+60
-4
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2021 by M5Stack
4+
* Equipped with M5Core sample source code
5+
* 配套 M5Core 示例源代码
6+
* Visit for more information: https://docs.m5stack.com/en/unit/encoder
7+
* 获取更多资料请访问: https://docs.m5stack.com/zh_CN/unit/encoder
8+
*
9+
* Describe: Encoder. 旋转编码器
10+
* Date: 2022/7/11
11+
*******************************************************************************
12+
Display of rotary encoder values and key status on the screen
13+
在屏幕上显示旋转编码器的值和按键状态
14+
*/
15+
#include <M5Core2.h>
16+
#include <M5GFX.h>
17+
#include "Unit_Encoder.h"
18+
19+
M5GFX display;
20+
M5Canvas canvas(&display);
21+
Unit_Encoder sensor;
22+
23+
void setup() {
24+
M5.begin(true, false, true, true); // Init M5Core2. 初始化M5Core2
25+
sensor.begin();
26+
display.begin();
27+
display.setRotation(1);
28+
canvas.setTextSize(2);
29+
canvas.createSprite(160, 80);
30+
}
31+
32+
signed short int last_value = 0;
33+
34+
void loop() {
35+
signed short int encoder_value = sensor.getEncoderValue();
36+
bool btn_stauts = sensor.getButtonStatus();
37+
Serial.println(encoder_value);
38+
if (last_value != encoder_value) {
39+
if (last_value > encoder_value) {
40+
sensor.setLEDColor(1, 0x000011);
41+
} else {
42+
sensor.setLEDColor(2, 0x111100);
43+
}
44+
last_value = encoder_value;
45+
} else {
46+
sensor.setLEDColor(0, 0x001100);
47+
}
48+
if (!btn_stauts) {
49+
sensor.setLEDColor(0, 0xC800FF);
50+
}
51+
canvas.fillSprite(BLACK);
52+
canvas.drawString("BTN:" + String(btn_stauts), 10, 10);
53+
canvas.drawString("ENCODER:" + String(encoder_value), 10, 40);
54+
canvas.pushSprite(0, 0);
55+
delay(20);
56+
}

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"type": "git",
1111
"url": "https://github.com/m5stack/M5Unit-Encoder.git"
1212
},
13-
"version": "0.0.1",
13+
"version": "0.0.2",
1414
"frameworks": "arduino",
1515
"platforms": "espressif32"
1616
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=M5Unit-Encoder
2-
version=0.0.1
2+
version=0.0.2
33
author=M5Stack
44
maintainer=M5Stack
55
sentence=Library for M5Stack Unit Encoder

src/Unit_Encoder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @copyright Copyright (c) 2022 by M5Stack[https://m5stack.com]
44
*
55
* @Links [Unit Encoder](https://docs.m5stack.com/en/unit/encoder)
6-
* @version V0.0.1
6+
* @version V0.0.2
77
* @date 2022-07-11
88
*/
99
#ifndef _UNIT_ENCODER_H_
@@ -24,7 +24,7 @@ class Unit_Encoder {
2424
TwoWire* _wire;
2525
uint8_t _scl;
2626
uint8_t _sda;
27-
uint8_t _speed;
27+
uint32_t _speed;
2828
void writeBytes(uint8_t addr, uint8_t reg, uint8_t* buffer, uint8_t length);
2929
void readBytes(uint8_t addr, uint8_t reg, uint8_t* buffer, uint8_t length);
3030

0 commit comments

Comments
 (0)