Pretty printed the Arduino code with astyle
This commit is contained in:
@@ -1,78 +1,73 @@
|
|||||||
/*
|
/*
|
||||||
* HT16K33_driver.cpp
|
HT16K33_driver.cpp
|
||||||
* A library for Grove - grove_quad_alphanumeric_display
|
A library for Grove - grove_quad_alphanumeric_display
|
||||||
*
|
|
||||||
* Copyright (c) 2018 seeed technology inc.
|
Copyright (c) 2018 seeed technology inc.
|
||||||
* Website : www.seeed.cc
|
Website : www.seeed.cc
|
||||||
* Author : Jerry Yip
|
Author : Jerry Yip
|
||||||
* Create Time: 2018-06
|
Create Time: 2018-06
|
||||||
* Version : 0.1
|
Version : 0.1
|
||||||
* Change Log :
|
Change Log :
|
||||||
* Copyright (c) 2018 seeed technology inc.
|
Copyright (c) 2018 seeed technology inc.
|
||||||
* Website : www.seeed.cc
|
Website : www.seeed.cc
|
||||||
* Author : downey
|
Author : downey
|
||||||
* Create Time: 2018-06
|
Create Time: 2018-06
|
||||||
* Version : 1.1
|
Version : 1.1
|
||||||
* Change Log :for digital tube development.
|
Change Log :for digital tube development.
|
||||||
*
|
|
||||||
* The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
* in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
* furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
* all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "HT16K33_driver.h"
|
#include "HT16K33_driver.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool HT16K33::writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t* data)
|
bool HT16K33::writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t* data) {
|
||||||
{
|
|
||||||
Wire.beginTransmission(devAddr);
|
Wire.beginTransmission(devAddr);
|
||||||
Wire.write((uint8_t) regAddr);
|
Wire.write((uint8_t) regAddr);
|
||||||
for (uint8_t i = 0; i < length; i++) {
|
for (uint8_t i = 0; i < length; i++) {
|
||||||
Wire.write((uint8_t) data[i]);
|
Wire.write((uint8_t) data[i]);
|
||||||
}
|
}
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void HT16K33::init(uint8_t addr)
|
void HT16K33::init(uint8_t addr) {
|
||||||
{
|
|
||||||
_addr = addr;
|
_addr = addr;
|
||||||
// turn on oscillator
|
// turn on oscillator
|
||||||
writeBytes(_addr, 0x21, 0, (uint8_t *)NULL);
|
writeBytes(_addr, 0x21, 0, (uint8_t*)NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*brightness:0-15*/
|
/*brightness:0-15*/
|
||||||
void HT16K33::setBrightness(uint8_t brightness)
|
void HT16K33::setBrightness(uint8_t brightness) {
|
||||||
{
|
writeBytes(_addr, (0xE0 | brightness), 0, (uint8_t*)NULL);
|
||||||
writeBytes(_addr, (0xE0 | brightness), 0, (uint8_t *)NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void HT16K33::setBlinkRate(blink_type_t blink_type)
|
void HT16K33::setBlinkRate(blink_type_t blink_type) {
|
||||||
{
|
writeBytes(_addr, (0x80 | 0x01 | (blink_type << 1)), 0, (uint8_t*)NULL);
|
||||||
writeBytes(_addr, (0x80 | 0x01 | (blink_type << 1)), 0, (uint8_t *)NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HT16K33::clear()
|
void HT16K33::clear() {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,40 +1,40 @@
|
|||||||
/*
|
/*
|
||||||
* HT16K33_driver.h
|
HT16K33_driver.h
|
||||||
* A library for Grove - grove_quad_alphanumeric_display
|
A library for Grove - grove_quad_alphanumeric_display
|
||||||
*
|
|
||||||
* Copyright (c) 2018 seeed technology inc.
|
Copyright (c) 2018 seeed technology inc.
|
||||||
* Website : www.seeed.cc
|
Website : www.seeed.cc
|
||||||
* Author : Jerry Yip
|
Author : Jerry Yip
|
||||||
* Create Time: 2018-06
|
Create Time: 2018-06
|
||||||
* Version : 0.1
|
Version : 0.1
|
||||||
* Change Log :
|
Change Log :
|
||||||
* Copyright (c) 2018 seeed technology inc.
|
Copyright (c) 2018 seeed technology inc.
|
||||||
* Website : www.seeed.cc
|
Website : www.seeed.cc
|
||||||
* Author : downey
|
Author : downey
|
||||||
* Create Time: 2018-06
|
Create Time: 2018-06
|
||||||
* Version : 1.1
|
Version : 1.1
|
||||||
* Change Log :for digital tube development.
|
Change Log :for digital tube development.
|
||||||
*
|
|
||||||
* The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
* in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
* furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
* all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#ifndef __HT16K33_DRIVER_H_
|
#ifndef __HT16K33_DRIVER_H_
|
||||||
#define __HT16K33_DRIVER_H_
|
#define __HT16K33_DRIVER_H_
|
||||||
|
|
||||||
@@ -46,22 +46,19 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
enum orientation_type_t
|
enum orientation_type_t {
|
||||||
{
|
|
||||||
DISPLAY_ROTATE_0 = 0,
|
DISPLAY_ROTATE_0 = 0,
|
||||||
DISPLAY_ROTATE_90,
|
DISPLAY_ROTATE_90,
|
||||||
DISPLAY_ROTATE_180,
|
DISPLAY_ROTATE_180,
|
||||||
DISPLAY_ROTATE_270,
|
DISPLAY_ROTATE_270,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum action_type_t
|
enum action_type_t {
|
||||||
{
|
|
||||||
ACTION_SCROLLING = 0,
|
ACTION_SCROLLING = 0,
|
||||||
ACTION_SHIFT,
|
ACTION_SHIFT,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum blink_type_t
|
enum blink_type_t {
|
||||||
{
|
|
||||||
BLINK_OFF = 0,
|
BLINK_OFF = 0,
|
||||||
BLINK_2HZ,
|
BLINK_2HZ,
|
||||||
BLINK_1HZ,
|
BLINK_1HZ,
|
||||||
@@ -69,20 +66,20 @@ enum blink_type_t
|
|||||||
|
|
||||||
|
|
||||||
class HT16K33 {
|
class HT16K33 {
|
||||||
public:
|
public:
|
||||||
HT16K33(){};
|
HT16K33() {};
|
||||||
|
|
||||||
void init(uint8_t addr);
|
void init(uint8_t addr);
|
||||||
|
|
||||||
void setBlinkRate(blink_type_t blink_type);
|
void setBlinkRate(blink_type_t blink_type);
|
||||||
|
|
||||||
void setBrightness(uint8_t brightness);
|
void setBrightness(uint8_t brightness);
|
||||||
|
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t* data);
|
bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t* data);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint8_t _addr;
|
uint8_t _addr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,29 +5,28 @@
|
|||||||
Seeed_Digital_Tube tube1;
|
Seeed_Digital_Tube tube1;
|
||||||
Seeed_Digital_Tube tube2;
|
Seeed_Digital_Tube tube2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOTICE:Every tubes display has the same default i2c address.
|
NOTICE:Every tubes display has the same default i2c address.
|
||||||
* if you want to combine two(or more)display in one project,you should change the
|
if you want to combine two(or more)display in one project,you should change the
|
||||||
* i2c address,by soldering the pad of device's backside.
|
i2c address,by soldering the pad of device's backside.
|
||||||
* please refer to our wiki to get more details.
|
please refer to our wiki to get more details.
|
||||||
* */
|
* */
|
||||||
#define I2C_ADDR_AFTER_CHANGE_FOUR 0x75
|
#define I2C_ADDR_AFTER_CHANGE_FOUR 0x75
|
||||||
#define I2C_ADDR_DEFAULT_FOUR 0x71
|
#define I2C_ADDR_DEFAULT_FOUR 0x71
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setup()
|
void setup() {
|
||||||
{
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
// If using four digital tubes, use this configuration.
|
// If using four digital tubes, use this configuration.
|
||||||
tube1.setTubeType(TYPE_4,I2C_ADDR_AFTER_CHANGE_FOUR);
|
tube1.setTubeType(TYPE_4, I2C_ADDR_AFTER_CHANGE_FOUR);
|
||||||
|
|
||||||
tube1.setBrightness(15);
|
tube1.setBrightness(15);
|
||||||
tube1.setBlinkRate(BLINK_OFF);
|
tube1.setBlinkRate(BLINK_OFF);
|
||||||
|
|
||||||
// If using four digital tubes, use this configuration.
|
// If using four digital tubes, use this configuration.
|
||||||
tube2.setTubeType(TYPE_4,I2C_ADDR_DEFAULT_FOUR);
|
tube2.setTubeType(TYPE_4, I2C_ADDR_DEFAULT_FOUR);
|
||||||
|
|
||||||
tube2.setBrightness(15);
|
tube2.setBrightness(15);
|
||||||
tube2.setBlinkRate(BLINK_OFF);
|
tube2.setBlinkRate(BLINK_OFF);
|
||||||
@@ -35,15 +34,14 @@ void setup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop()
|
void loop() {
|
||||||
{
|
|
||||||
tube1.displayNum(1234);
|
tube1.displayNum(1234);
|
||||||
delay(100);
|
delay(100);
|
||||||
|
|
||||||
tube2.displayNum(5678);
|
tube2.displayNum(5678);
|
||||||
delay(100);
|
delay(100);
|
||||||
|
|
||||||
while(1);
|
while (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,68 +1,66 @@
|
|||||||
/*
|
/*
|
||||||
* display_basic.ino
|
display_basic.ino
|
||||||
* Example for digital tube.
|
Example for digital tube.
|
||||||
*
|
|
||||||
* Copyright (c) 2018 Seeed Technology Co., Ltd.
|
Copyright (c) 2018 Seeed Technology Co., Ltd.
|
||||||
* Website : www.seeed.cc
|
Website : www.seeed.cc
|
||||||
* Author : downey
|
Author : downey
|
||||||
* Create Time: sep. 2018
|
Create Time: sep. 2018
|
||||||
* Change Log :
|
Change Log :
|
||||||
*
|
|
||||||
* The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
* in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
* furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
* all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
#include "grove_alphanumeric_display.h"
|
#include "grove_alphanumeric_display.h"
|
||||||
|
|
||||||
Seeed_Digital_Tube tube;
|
Seeed_Digital_Tube tube;
|
||||||
|
|
||||||
void setup()
|
void setup() {
|
||||||
{
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
// If using four digital tubes, use this configuration.
|
// If using four digital tubes, use this configuration.
|
||||||
tube.setTubeType(TYPE_4,TYPE_4_DEFAULT_I2C_ADDR);
|
tube.setTubeType(TYPE_4, TYPE_4_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
// If using two digital tubes, use this configuration.
|
// If using two digital tubes, use this configuration.
|
||||||
// tube.setTubeType(TYPE_2,TYPE_2_DEFAULT_I2C_ADDR);
|
// tube.setTubeType(TYPE_2,TYPE_2_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
tube.setBrightness(15);
|
tube.setBrightness(15);
|
||||||
tube.setBlinkRate(BLINK_OFF);
|
tube.setBlinkRate(BLINK_OFF);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop()
|
void loop() {
|
||||||
{
|
|
||||||
|
|
||||||
tube.displayNum(12);
|
tube.displayNum(12);
|
||||||
delay(2000);
|
delay(2000);
|
||||||
|
|
||||||
tube.displayNum(4567,500);
|
tube.displayNum(4567, 500);
|
||||||
delay(2000);
|
delay(2000);
|
||||||
|
|
||||||
tube.displayString("AB",500);
|
tube.displayString("AB", 500);
|
||||||
delay(2000);
|
delay(2000);
|
||||||
|
|
||||||
tube.displayString("abcd",500);
|
tube.displayString("abcd", 500);
|
||||||
delay(2000);
|
delay(2000);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,33 +1,33 @@
|
|||||||
/*
|
/*
|
||||||
* display_custom.ino
|
display_custom.ino
|
||||||
* Example for digital tube.
|
Example for digital tube.
|
||||||
*
|
|
||||||
* Copyright (c) 2018 Seeed Technology Co., Ltd.
|
Copyright (c) 2018 Seeed Technology Co., Ltd.
|
||||||
* Website : www.seeed.cc
|
Website : www.seeed.cc
|
||||||
* Author : downey
|
Author : downey
|
||||||
* Create Time: sep. 2018
|
Create Time: sep. 2018
|
||||||
* Change Log :
|
Change Log :
|
||||||
*
|
|
||||||
* The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
* in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
* furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
* all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -36,43 +36,40 @@
|
|||||||
Seeed_Digital_Tube tube;
|
Seeed_Digital_Tube tube;
|
||||||
|
|
||||||
|
|
||||||
void setup()
|
void setup() {
|
||||||
{
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
// If using two digital tubes, use this configuration.
|
// If using two digital tubes, use this configuration.
|
||||||
// tube.setTubeType(TYPE_2,TYPE_2_DEFAULT_I2C_ADDR);
|
// tube.setTubeType(TYPE_2,TYPE_2_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
// If using four digital tubes, use this configuration.
|
// If using four digital tubes, use this configuration.
|
||||||
tube.setTubeType(TYPE_4,TYPE_4_DEFAULT_I2C_ADDR);
|
tube.setTubeType(TYPE_4, TYPE_4_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
|
|
||||||
tube.setBrightness(15);
|
tube.setBrightness(15);
|
||||||
tube.setBlinkRate(BLINK_1HZ);
|
tube.setBlinkRate(BLINK_1HZ);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void displayCustom()
|
void displayCustom() {
|
||||||
{
|
|
||||||
tube.clearBuf();
|
tube.clearBuf();
|
||||||
tube.setTubeSingleChar(FIRST_TUBE,'t');
|
tube.setTubeSingleChar(FIRST_TUBE, 't');
|
||||||
tube.setTubeSingleChar(SECOND_TUBE,'T');
|
tube.setTubeSingleChar(SECOND_TUBE, 'T');
|
||||||
|
|
||||||
//if using two digital tubes,there's no third&fourth channel.
|
//if using two digital tubes,there's no third&fourth channel.
|
||||||
|
|
||||||
tube.setTubeSingleNum(THIRD_TUBE,5);
|
tube.setTubeSingleNum(THIRD_TUBE, 5);
|
||||||
tube.setTubeSingleNum(FOURTH_TUBE,5);
|
tube.setTubeSingleNum(FOURTH_TUBE, 5);
|
||||||
|
|
||||||
// The location of point is different between two&four digital tubes.
|
// The location of point is different between two&four digital tubes.
|
||||||
tube.setPoint(true,false);
|
tube.setPoint(true, false);
|
||||||
|
|
||||||
tube.display();
|
tube.display();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop() {
|
||||||
{
|
|
||||||
displayCustom();
|
displayCustom();
|
||||||
delay(2000);
|
delay(2000);
|
||||||
}
|
}
|
||||||
@@ -1,33 +1,33 @@
|
|||||||
/*
|
/*
|
||||||
* display_scroll_number.ino
|
display_scroll_number.ino
|
||||||
* Example for digital tube.
|
Example for digital tube.
|
||||||
*
|
|
||||||
* Copyright (c) 2018 Seeed Technology Co., Ltd.
|
Copyright (c) 2018 Seeed Technology Co., Ltd.
|
||||||
* Website : www.seeed.cc
|
Website : www.seeed.cc
|
||||||
* Author : downey
|
Author : downey
|
||||||
* Create Time: sep. 2018
|
Create Time: sep. 2018
|
||||||
* Change Log :
|
Change Log :
|
||||||
*
|
|
||||||
* The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
* in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
* furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
* all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include "grove_alphanumeric_display.h"
|
#include "grove_alphanumeric_display.h"
|
||||||
|
|
||||||
@@ -36,15 +36,14 @@ Seeed_Digital_Tube tube;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setup()
|
void setup() {
|
||||||
{
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
// If using two digital tubes, use this configuration.
|
// If using two digital tubes, use this configuration.
|
||||||
// tube.setTubeType(TYPE_2,TYPE_2_DEFAULT_I2C_ADDR);
|
// tube.setTubeType(TYPE_2,TYPE_2_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
// If using four digital tubes, use this configuration.
|
// If using four digital tubes, use this configuration.
|
||||||
tube.setTubeType(TYPE_4,TYPE_4_DEFAULT_I2C_ADDR);
|
tube.setTubeType(TYPE_4, TYPE_4_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
tube.setBrightness(15);
|
tube.setBrightness(15);
|
||||||
tube.setBlinkRate(BLINK_OFF);
|
tube.setBlinkRate(BLINK_OFF);
|
||||||
@@ -52,8 +51,7 @@ void setup()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void loop()
|
void loop() {
|
||||||
{
|
tube.displayNum(1234567, 500);
|
||||||
tube.displayNum(1234567,500);
|
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
@@ -1,33 +1,33 @@
|
|||||||
/*
|
/*
|
||||||
* display_scroll_string.ino
|
display_scroll_string.ino
|
||||||
* Driver for digital tube.
|
Driver for digital tube.
|
||||||
*
|
|
||||||
* Copyright (c) 2018 Seeed Technology Co., Ltd.
|
Copyright (c) 2018 Seeed Technology Co., Ltd.
|
||||||
* Website : www.seeed.cc
|
Website : www.seeed.cc
|
||||||
* Author : downey
|
Author : downey
|
||||||
* Create Time: sep. 2018
|
Create Time: sep. 2018
|
||||||
* Change Log :
|
Change Log :
|
||||||
*
|
|
||||||
* The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
* in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
* furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
* all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include "grove_alphanumeric_display.h"
|
#include "grove_alphanumeric_display.h"
|
||||||
|
|
||||||
@@ -35,15 +35,14 @@ Seeed_Digital_Tube tube;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setup()
|
void setup() {
|
||||||
{
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
// If using two digital tubes, use this configuration.
|
// If using two digital tubes, use this configuration.
|
||||||
// tube.setTubeType(TYPE_2,TYPE_2_DEFAULT_I2C_ADDR);
|
// tube.setTubeType(TYPE_2,TYPE_2_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
// If using four digital tubes, use this configuration.
|
// If using four digital tubes, use this configuration.
|
||||||
tube.setTubeType(TYPE_4,TYPE_4_DEFAULT_I2C_ADDR);
|
tube.setTubeType(TYPE_4, TYPE_4_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
tube.setBrightness(15);
|
tube.setBrightness(15);
|
||||||
tube.setBlinkRate(BLINK_OFF);
|
tube.setBlinkRate(BLINK_OFF);
|
||||||
@@ -51,8 +50,7 @@ void setup()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void loop()
|
void loop() {
|
||||||
{
|
tube.displayString("ABCDEFGHIJK", 500);
|
||||||
tube.displayString("ABCDEFGHIJK",500);
|
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
@@ -1,30 +1,30 @@
|
|||||||
/*
|
/*
|
||||||
display_basic.ino
|
display_basic.ino
|
||||||
Example for displaying specific segments on a tube.
|
Example for displaying specific segments on a tube.
|
||||||
|
|
||||||
|
|
||||||
Author : dagwoodland
|
Author : dagwoodland
|
||||||
Create Time: Sep 2019
|
Create Time: Sep 2019
|
||||||
|
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Wire.h"
|
#include "Wire.h"
|
||||||
@@ -35,20 +35,20 @@ int currentSegment = 0;
|
|||||||
|
|
||||||
// The frames of tube 2's animation.
|
// The frames of tube 2's animation.
|
||||||
uint16_t tubeTwoFrames[] = {
|
uint16_t tubeTwoFrames[] = {
|
||||||
SEGMENT_TOP,
|
SEGMENT_TOP,
|
||||||
SEGMENT_TOP_LEFT,
|
SEGMENT_TOP_LEFT,
|
||||||
SEGMENT_TOP_LEFT_DIAGONAL,
|
SEGMENT_TOP_LEFT_DIAGONAL,
|
||||||
SEGMENT_TOP_VERTICAL,
|
SEGMENT_TOP_VERTICAL,
|
||||||
SEGMENT_TOP_RIGHT_DIAGONAL,
|
SEGMENT_TOP_RIGHT_DIAGONAL,
|
||||||
SEGMENT_TOP_RIGHT,
|
SEGMENT_TOP_RIGHT,
|
||||||
SEGMENT_MIDDLE_LEFT,
|
SEGMENT_MIDDLE_LEFT,
|
||||||
SEGMENT_MIDDLE_RIGHT,
|
SEGMENT_MIDDLE_RIGHT,
|
||||||
SEGMENT_BOTTOM_LEFT,
|
SEGMENT_BOTTOM_LEFT,
|
||||||
SEGMENT_BOTTOM_LEFT_DIAGONAL,
|
SEGMENT_BOTTOM_LEFT_DIAGONAL,
|
||||||
SEGMENT_BOTTOM_VERTICAL,
|
SEGMENT_BOTTOM_VERTICAL,
|
||||||
SEGMENT_BOTTOM_RIGHT_DIAGONAL,
|
SEGMENT_BOTTOM_RIGHT_DIAGONAL,
|
||||||
SEGMENT_BOTTOM_RIGHT,
|
SEGMENT_BOTTOM_RIGHT,
|
||||||
SEGMENT_BOTTOM
|
SEGMENT_BOTTOM
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------
|
// -----------------------------------------------------------
|
||||||
@@ -61,50 +61,50 @@ uint16_t tubeTwoFrames[] = {
|
|||||||
Seeed_Digital_Tube tube;
|
Seeed_Digital_Tube tube;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
// Setup wire using default I2C pins.
|
// Setup wire using default I2C pins.
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
// If using four digital tubes, use this configuration.
|
// If using four digital tubes, use this configuration.
|
||||||
tube.setTubeType(TYPE_4, TYPE_4_DEFAULT_I2C_ADDR);
|
tube.setTubeType(TYPE_4, TYPE_4_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
// If using two digital tubes, use this configuration.
|
// If using two digital tubes, use this configuration.
|
||||||
// tube.setTubeType(TYPE_2,TYPE_2_DEFAULT_I2C_ADDR);
|
// tube.setTubeType(TYPE_2,TYPE_2_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
tube.setBrightness(15);
|
tube.setBrightness(15);
|
||||||
tube.setBlinkRate(BLINK_OFF);
|
tube.setBlinkRate(BLINK_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display the top and bottom segments on the first tube.
|
// Display the top and bottom segments on the first tube.
|
||||||
void displayTubeOne() {
|
void displayTubeOne() {
|
||||||
// To display specific segments add together their values.
|
// To display specific segments add together their values.
|
||||||
tube.setTubeSegments(FIRST_TUBE, SEGMENT_TOP + SEGMENT_BOTTOM);
|
tube.setTubeSegments(FIRST_TUBE, SEGMENT_TOP + SEGMENT_BOTTOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display an animation going through all 14 segments in turn.
|
// Display an animation going through all 14 segments in turn.
|
||||||
void displayTubeTwo() {
|
void displayTubeTwo() {
|
||||||
// Increment tube 2's animation frame.
|
// Increment tube 2's animation frame.
|
||||||
currentSegment += 1;
|
currentSegment += 1;
|
||||||
|
|
||||||
// Restart the animation if it has finished.
|
// Restart the animation if it has finished.
|
||||||
if (currentSegment >= 14) {
|
if (currentSegment >= 14) {
|
||||||
currentSegment = 0;
|
currentSegment = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display the current frame of tube 2's animation.
|
// Display the current frame of tube 2's animation.
|
||||||
tube.setTubeSegments(SECOND_TUBE, tubeTwoFrames[currentSegment]);
|
tube.setTubeSegments(SECOND_TUBE, tubeTwoFrames[currentSegment]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// Clear the tube's buffer. Using tube.clearBuf() prevents
|
// Clear the tube's buffer. Using tube.clearBuf() prevents
|
||||||
// the display blinking because the display is not updated
|
// the display blinking because the display is not updated
|
||||||
// until tube.display() is called, unlike tube.clear()
|
// until tube.display() is called, unlike tube.clear()
|
||||||
tube.clearBuf();
|
tube.clearBuf();
|
||||||
|
|
||||||
displayTubeOne();
|
displayTubeOne();
|
||||||
displayTubeTwo();
|
displayTubeTwo();
|
||||||
|
|
||||||
// Display the new contents of both tube's buffers.
|
// Display the new contents of both tube's buffers.
|
||||||
tube.display();
|
tube.display();
|
||||||
|
|
||||||
delay(200);
|
delay(200);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,33 @@
|
|||||||
/*
|
/*
|
||||||
* number_increment.ino
|
number_increment.ino
|
||||||
* Driver for digital tube.
|
Driver for digital tube.
|
||||||
*
|
|
||||||
* Copyright (c) 2018 Seeed Technology Co., Ltd.
|
Copyright (c) 2018 Seeed Technology Co., Ltd.
|
||||||
* Website : www.seeed.cc
|
Website : www.seeed.cc
|
||||||
* Author : downey
|
Author : downey
|
||||||
* Create Time: sep. 2018
|
Create Time: sep. 2018
|
||||||
* Change Log :
|
Change Log :
|
||||||
*
|
|
||||||
* The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
* in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
* furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
* all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include "grove_alphanumeric_display.h"
|
#include "grove_alphanumeric_display.h"
|
||||||
|
|
||||||
@@ -36,51 +36,43 @@ Seeed_Digital_Tube tube;
|
|||||||
|
|
||||||
char hex_str[10];
|
char hex_str[10];
|
||||||
|
|
||||||
void setup()
|
void setup() {
|
||||||
{
|
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
// If using two digital tubes, use this configuration.
|
// If using two digital tubes, use this configuration.
|
||||||
// tube.setTubeType(TYPE_2,TYPE_2_DEFAULT_I2C_ADDR);
|
// tube.setTubeType(TYPE_2,TYPE_2_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
// If using four digital tubes, use this configuration.
|
// If using four digital tubes, use this configuration.
|
||||||
tube.setTubeType(TYPE_4,TYPE_4_DEFAULT_I2C_ADDR);
|
tube.setTubeType(TYPE_4, TYPE_4_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
tube.setBrightness(15);
|
tube.setBrightness(15);
|
||||||
tube.setBlinkRate(BLINK_OFF);
|
tube.setBlinkRate(BLINK_OFF);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char* numToHexString(unsigned int num)
|
char* numToHexString(unsigned int num) {
|
||||||
{
|
if (num <= 0xf) {
|
||||||
if(num <= 0xf){
|
sprintf(hex_str, "0%x", num);
|
||||||
sprintf(hex_str,"0%x",num);
|
for (int i = 0; i < 2; i++) {
|
||||||
for(int i=0;i<2;i++)
|
if (hex_str[i] >= 'a' && hex_str[i] <= 'z') {
|
||||||
{
|
hex_str[i] -= 0x20;
|
||||||
if(hex_str[i] >= 'a' && hex_str[i] <= 'z')
|
|
||||||
{
|
|
||||||
hex_str[i] -=0x20;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return hex_str;
|
return hex_str;
|
||||||
}
|
}
|
||||||
sprintf(hex_str,"%x",num);
|
sprintf(hex_str, "%x", num);
|
||||||
for(int i=0;i<2;i++)
|
for (int i = 0; i < 2; i++) {
|
||||||
{
|
if (hex_str[i] >= 'a' && hex_str[i] <= 'z') {
|
||||||
if(hex_str[i] >= 'a' && hex_str[i] <= 'z')
|
hex_str[i] -= 0x20;
|
||||||
{
|
|
||||||
hex_str[i] -=0x20;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return hex_str;
|
return hex_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop()
|
void loop() {
|
||||||
{
|
for (int i = 0; i < 0xff; i++) {
|
||||||
for(int i=0;i<0xff;i++)
|
tube.displayString(numToHexString(i), 0);
|
||||||
{
|
|
||||||
tube.displayString(numToHexString(i),0);
|
|
||||||
delay(100);
|
delay(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,46 +1,46 @@
|
|||||||
/*
|
/*
|
||||||
* grove_alphanumeric_display.cpp
|
grove_alphanumeric_display.cpp
|
||||||
* A library for Grove - grove_alphanumeric_display
|
A library for Grove - grove_alphanumeric_display
|
||||||
*
|
|
||||||
* Copyright (c) 2018 seeed technology inc.
|
Copyright (c) 2018 seeed technology inc.
|
||||||
* Website : www.seeed.cc
|
Website : www.seeed.cc
|
||||||
* Author : Jerry Yip
|
Author : Jerry Yip
|
||||||
* Create Time: 2018-06
|
Create Time: 2018-06
|
||||||
* Version : 0.1
|
Version : 0.1
|
||||||
* Change Log :
|
Change Log :
|
||||||
* Copyright (c) 2018 seeed technology inc.
|
Copyright (c) 2018 seeed technology inc.
|
||||||
* Website : www.seeed.cc
|
Website : www.seeed.cc
|
||||||
* Author : downey
|
Author : downey
|
||||||
* Create Time: 2018-06
|
Create Time: 2018-06
|
||||||
* Version : 1.1
|
Version : 1.1
|
||||||
* Change Log :for digital tube development.
|
Change Log :for digital tube development.
|
||||||
*
|
|
||||||
* The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
* in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
* furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
* all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "grove_alphanumeric_display.h"
|
#include "grove_alphanumeric_display.h"
|
||||||
#include "Wire.h"
|
#include "Wire.h"
|
||||||
|
|
||||||
|
|
||||||
uint16_t g_display_font4[]={
|
uint16_t g_display_font4[] = {
|
||||||
// 0x0000, // display nothing.
|
// 0x0000, // display nothing.
|
||||||
0x0080, // 'upper .'
|
0x0080, // 'upper .'
|
||||||
0x2000, // 'lower .'
|
0x2000, // 'lower .'
|
||||||
@@ -86,7 +86,7 @@ uint16_t g_display_font4[]={
|
|||||||
|
|
||||||
|
|
||||||
#define LAST_ITEM 38
|
#define LAST_ITEM 38
|
||||||
uint16_t g_display_font2[]={
|
uint16_t g_display_font2[] = {
|
||||||
// 0x0000, // display nothing.
|
// 0x0000, // display nothing.
|
||||||
0x4000, // '.'
|
0x4000, // '.'
|
||||||
0x0000, // '/' display nothing.
|
0x0000, // '/' display nothing.
|
||||||
@@ -129,102 +129,92 @@ uint16_t g_display_font2[]={
|
|||||||
0x0000, // ilegal num
|
0x0000, // ilegal num
|
||||||
};
|
};
|
||||||
|
|
||||||
uint16_t segments4Tubes[] = {0x10,0x4000,0x80,0x40,0x2,0x2000,0x200,0x100,0x400,0x8,0x1000,0x20,0x4,0x800};
|
uint16_t segments4Tubes[] = {0x10, 0x4000, 0x80, 0x40, 0x2, 0x2000, 0x200, 0x100, 0x400, 0x8, 0x1000, 0x20, 0x4, 0x800};
|
||||||
uint16_t segments2Tubes[] = {0x4,0x40,0x20,0x1,0x8,0x10,0x2,0x1000,0x2000,0x100,0x200,0x8000,0x800,0x400};
|
uint16_t segments2Tubes[] = {0x4, 0x40, 0x20, 0x1, 0x8, 0x10, 0x2, 0x1000, 0x2000, 0x100, 0x200, 0x8000, 0x800, 0x400};
|
||||||
|
|
||||||
|
Seeed_Digital_Tube::Seeed_Digital_Tube() {
|
||||||
|
|
||||||
Seeed_Digital_Tube::Seeed_Digital_Tube()
|
|
||||||
{
|
|
||||||
|
|
||||||
_ms = 100;
|
_ms = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Seeed_Digital_Tube::setTubeType(TubeType_t type,uint8_t addr)
|
void Seeed_Digital_Tube::setTubeType(TubeType_t type, uint8_t addr) {
|
||||||
{
|
|
||||||
_type = type;
|
_type = type;
|
||||||
(_type == TYPE_2) ? (_tube_cnt = CNT_2) : (_tube_cnt = CNT_4);
|
(_type == TYPE_2) ? (_tube_cnt = CNT_2) : (_tube_cnt = CNT_4);
|
||||||
(_type == TYPE_2) ? (disp_font_p = g_display_font2) : (disp_font_p = g_display_font4);
|
(_type == TYPE_2) ? (disp_font_p = g_display_font2) : (disp_font_p = g_display_font4);
|
||||||
HT16K33::init(addr);
|
HT16K33::init(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Seeed_Digital_Tube::isLegalToDisplay(char byte)
|
bool Seeed_Digital_Tube::isLegalToDisplay(char byte) {
|
||||||
{
|
if (!((byte >= '.' && byte <= '9') || (byte >= 'A' && byte <= 'Z') || (byte >= 'a' && byte <= 'z'))) {
|
||||||
if( !((byte >= '.' && byte <= '9') || (byte >= 'A' && byte <= 'Z') || (byte >= 'a' && byte <= 'z') ) )
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**@brief Display number,If the param-num's len less than 4(or equal to),The tubes display static number,otherwise,it displays scroll number.
|
/** @brief Display number,If the param-num's len less than 4(or equal to),The tubes display static number,otherwise,it displays scroll number.
|
||||||
* When it displays scroll number,the param interval is scrolling interval(ms) ..
|
When it displays scroll number,the param interval is scrolling interval(ms) ..
|
||||||
* @param num the number to display.
|
@param num the number to display.
|
||||||
* @param interval :the interval of scroll number.
|
@param interval :the interval of scroll number.
|
||||||
* */
|
* */
|
||||||
void Seeed_Digital_Tube::displayNum(uint32_t num,uint32_t interval)
|
void Seeed_Digital_Tube::displayNum(uint32_t num, uint32_t interval) {
|
||||||
{
|
|
||||||
char num_str[15] = {0};
|
char num_str[15] = {0};
|
||||||
sprintf(num_str,"%ld",(uint32_t)num);
|
sprintf(num_str, "%ld", (uint32_t)num);
|
||||||
displayString(num_str,interval);
|
displayString(num_str, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Seeed_Digital_Tube::shiftDisplay(char *origin_disp_buf,char new_item)
|
void Seeed_Digital_Tube::shiftDisplay(char* origin_disp_buf, char new_item) {
|
||||||
{
|
|
||||||
char temp[MAX_TUBE_COUNT] = {0};
|
char temp[MAX_TUBE_COUNT] = {0};
|
||||||
|
|
||||||
memcpy(temp,&origin_disp_buf[1],_tube_cnt - 1);
|
memcpy(temp, &origin_disp_buf[1], _tube_cnt - 1);
|
||||||
|
|
||||||
temp[_tube_cnt-1] = new_item;
|
temp[_tube_cnt - 1] = new_item;
|
||||||
|
|
||||||
memcpy(origin_disp_buf,temp,_tube_cnt);
|
memcpy(origin_disp_buf, temp, _tube_cnt);
|
||||||
|
|
||||||
|
for (int i = 0; i < _tube_cnt; i++) {
|
||||||
|
setTubeBuf((TubeNum)(i + 1), temp[i]);
|
||||||
|
|
||||||
for(int i =0;i< _tube_cnt;i++)
|
|
||||||
{
|
|
||||||
setTubeBuf((TubeNum)(i+1),temp[i]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
writeBytes(_addr, 0x00, 16, _buffer);
|
writeBytes(_addr, 0x00, 16, _buffer);
|
||||||
delay(_ms);
|
delay(_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Display string,If the param-str's len less than 4(or equal to),The tubes display static string,otherwise,it displays scroll string.
|
/** @brief Display string,If the param-str's len less than 4(or equal to),The tubes display static string,otherwise,it displays scroll string.
|
||||||
* When it displays scroll string,the param interval is scrolling interval(ms) ..
|
When it displays scroll string,the param interval is scrolling interval(ms) ..
|
||||||
* @param str the str to display.
|
@param str the str to display.
|
||||||
* @param interval :the interval of scroll string.
|
@param interval :the interval of scroll string.
|
||||||
* */
|
* */
|
||||||
void Seeed_Digital_Tube::displayString(char *str,uint32_t interval)
|
void Seeed_Digital_Tube::displayString(char* str, uint32_t interval) {
|
||||||
{
|
|
||||||
int len = 0;
|
int len = 0;
|
||||||
clearBuf();
|
clearBuf();
|
||||||
|
|
||||||
len = strlen(str);
|
len = strlen(str);
|
||||||
|
|
||||||
if(_tube_cnt >= len)
|
if (_tube_cnt >= len) {
|
||||||
{
|
for (int i = 0; i < len; i++) {
|
||||||
for(int i=0;i<len;i++)
|
|
||||||
{
|
|
||||||
//setTubeBuf((TubeNum)(_tube_cnt-len+i+1),disp_font_p[get_char_index(str[i])]); //Convert number to char;
|
//setTubeBuf((TubeNum)(_tube_cnt-len+i+1),disp_font_p[get_char_index(str[i])]); //Convert number to char;
|
||||||
setTubeBuf((TubeNum)(_tube_cnt-len+i+1),str[i]); //Convert number to char;
|
setTubeBuf((TubeNum)(_tube_cnt - len + i + 1), str[i]); //Convert number to char;
|
||||||
}
|
}
|
||||||
writeBytes(_addr, 0x00, 16, _buffer);
|
writeBytes(_addr, 0x00, 16, _buffer);
|
||||||
delay(_ms);
|
delay(_ms);
|
||||||
}
|
} else {
|
||||||
else
|
if (len > 255) {
|
||||||
{
|
len = 255;
|
||||||
if(len > 255 ) len = 255;
|
}
|
||||||
char origin_disp_buf[MAX_TUBE_COUNT]={0};
|
char origin_disp_buf[MAX_TUBE_COUNT] = {0};
|
||||||
|
|
||||||
for(int i=0;i<len;i++)
|
for (int i = 0; i < len; i++) {
|
||||||
{
|
shiftDisplay(origin_disp_buf, str[i]);
|
||||||
shiftDisplay(origin_disp_buf,str[i]);
|
|
||||||
delay(interval);
|
delay(interval);
|
||||||
}
|
}
|
||||||
for(int i=0;i<_tube_cnt;i++)
|
for (int i = 0; i < _tube_cnt; i++) {
|
||||||
{
|
shiftDisplay(origin_disp_buf, 0);
|
||||||
shiftDisplay(origin_disp_buf,0);
|
|
||||||
delay(interval);
|
delay(interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,256 +222,216 @@ void Seeed_Digital_Tube::displayString(char *str,uint32_t interval)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Seeed_Digital_Tube::clear()
|
void Seeed_Digital_Tube::clear() {
|
||||||
{
|
|
||||||
memset(_buffer, 0, sizeof(_buffer));
|
memset(_buffer, 0, sizeof(_buffer));
|
||||||
writeBytes(_addr, 0x00, 16, _buffer);
|
writeBytes(_addr, 0x00, 16, _buffer);
|
||||||
delay(_ms);
|
delay(_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Seeed_Digital_Tube::fulDisplay()
|
void Seeed_Digital_Tube::fulDisplay() {
|
||||||
{
|
|
||||||
uint8_t buf[16] = {0};
|
uint8_t buf[16] = {0};
|
||||||
memcpy(_buffer,buf,sizeof(buf));
|
memcpy(_buffer, buf, sizeof(buf));
|
||||||
memset(_buffer, 0xff, sizeof(_buffer));
|
memset(_buffer, 0xff, sizeof(_buffer));
|
||||||
writeBytes(_addr, 0x00, 16, _buffer);
|
writeBytes(_addr, 0x00, 16, _buffer);
|
||||||
delay(_ms);
|
delay(_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** There are some differences of the hardware design of two kinds of display(two & four tubes).
|
/** There are some differences of the hardware design of two kinds of display(two & four tubes).
|
||||||
* two digital tubes use _buffer[2,3,4,5] to control display.
|
two digital tubes use _buffer[2,3,4,5] to control display.
|
||||||
* four digital tubes use _buffer[2,3,4,5,6,7,8,9,10,11] to control display.
|
four digital tubes use _buffer[2,3,4,5,6,7,8,9,10,11] to control display.
|
||||||
*
|
|
||||||
**/
|
|
||||||
void Seeed_Digital_Tube::replace_bit12(TubeNum tube_num,bool bit1,bool bit2)
|
|
||||||
{
|
|
||||||
switch(tube_num)
|
|
||||||
{
|
|
||||||
case FIRST_TUBE:
|
|
||||||
_buffer[10] &= ~(1 << 4);
|
|
||||||
_buffer[10] &= ~(1<<3);
|
|
||||||
|
|
||||||
_buffer[10] |= (bit1<<4);
|
**/
|
||||||
_buffer[10] |= (bit2<<3);
|
void Seeed_Digital_Tube::replace_bit12(TubeNum tube_num, bool bit1, bool bit2) {
|
||||||
break;
|
switch (tube_num) {
|
||||||
|
case FIRST_TUBE:
|
||||||
|
_buffer[10] &= ~(1 << 4);
|
||||||
|
_buffer[10] &= ~(1 << 3);
|
||||||
|
|
||||||
|
_buffer[10] |= (bit1 << 4);
|
||||||
|
_buffer[10] |= (bit2 << 3);
|
||||||
|
break;
|
||||||
case SECOND_TUBE:
|
case SECOND_TUBE:
|
||||||
|
|
||||||
_buffer[10] &= ~(1 << 6);
|
_buffer[10] &= ~(1 << 6);
|
||||||
_buffer[11] &= ~(1 << 6);
|
_buffer[11] &= ~(1 << 6);
|
||||||
|
|
||||||
_buffer[10] |= (bit1<<6);
|
_buffer[10] |= (bit1 << 6);
|
||||||
_buffer[11] |= (bit2<<6);
|
_buffer[11] |= (bit2 << 6);
|
||||||
break;
|
break;
|
||||||
case THIRD_TUBE:
|
case THIRD_TUBE:
|
||||||
_buffer[10] &= ~(1 << 5);
|
_buffer[10] &= ~(1 << 5);
|
||||||
_buffer[11] &= ~(1 << 1);
|
_buffer[11] &= ~(1 << 1);
|
||||||
|
|
||||||
_buffer[10] |= (bit1<<5);
|
_buffer[10] |= (bit1 << 5);
|
||||||
_buffer[11] |= (bit2<<1);
|
_buffer[11] |= (bit2 << 1);
|
||||||
break;
|
break;
|
||||||
case FOURTH_TUBE:
|
case FOURTH_TUBE:
|
||||||
_buffer[11] &= ~(1 << 2);
|
_buffer[11] &= ~(1 << 2);
|
||||||
_buffer[11] &= ~(1 << 0);
|
_buffer[11] &= ~(1 << 0);
|
||||||
|
|
||||||
_buffer[11] |= (bit1<<2);
|
_buffer[11] |= (bit1 << 2);
|
||||||
_buffer[11] |= (bit2<<0);
|
_buffer[11] |= (bit2 << 0);
|
||||||
break;
|
break;
|
||||||
default:break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Seeed_Digital_Tube::setPoint(bool first_dot,bool second_dot)
|
void Seeed_Digital_Tube::setPoint(bool first_dot, bool second_dot) {
|
||||||
{
|
if (TYPE_4 == _type) {
|
||||||
if( TYPE_4 == _type )
|
|
||||||
{
|
|
||||||
//upper dot control
|
//upper dot control
|
||||||
if(first_dot){
|
if (first_dot) {
|
||||||
_buffer[10] |= disp_font_p[0];
|
_buffer[10] |= disp_font_p[0];
|
||||||
_buffer[11] |= disp_font_p[0]>>8;
|
_buffer[11] |= disp_font_p[0] >> 8;
|
||||||
}
|
}
|
||||||
//lower dot control
|
//lower dot control
|
||||||
if(second_dot){
|
if (second_dot) {
|
||||||
_buffer[10] |= disp_font_p[1];
|
_buffer[10] |= disp_font_p[1];
|
||||||
_buffer[11] |= disp_font_p[1]>>8;
|
_buffer[11] |= disp_font_p[1] >> 8;
|
||||||
}
|
}
|
||||||
}
|
} else if (TYPE_2 == _type) {
|
||||||
else if (TYPE_2 == _type)
|
if (first_dot) {
|
||||||
{
|
_buffer[SECOND_TUBE * 2] |= disp_font_p[0] >> 8;
|
||||||
if(first_dot)
|
|
||||||
_buffer[SECOND_TUBE*2] |= disp_font_p[0] >> 8;
|
|
||||||
|
|
||||||
if(second_dot)
|
|
||||||
|
|
||||||
_buffer[FIRST_TUBE*2] |= disp_font_p[0] >> 8;
|
|
||||||
}
|
|
||||||
else{}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Seeed_Digital_Tube::setTubeSegments(TubeNum tube_num,uint16_t segments)
|
|
||||||
{
|
|
||||||
uint16_t value = 0;
|
|
||||||
|
|
||||||
if( TYPE_4 == _type )
|
|
||||||
{
|
|
||||||
for (int i=0; i<16; i++) {
|
|
||||||
if (bitRead(segments, i) == 1) {
|
|
||||||
value += segments4Tubes[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_buffer[tube_num*2] = value;
|
|
||||||
_buffer[tube_num*2+1] = value >> 8;
|
|
||||||
replace_bit12(tube_num,value&0x02,value&0x04);
|
|
||||||
}
|
|
||||||
else if (TYPE_2 == _type)
|
|
||||||
{
|
|
||||||
for (int i=0; i<16; i++) {
|
|
||||||
if (bitRead(segments, i) == 1) {
|
|
||||||
value += segments2Tubes[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set tube_num to 1 if it's 2, and 2 if it's 1, so that it's compatible with the hardware.
|
|
||||||
tube_num = (TubeNum) (((int)tube_num+1) & (~(int)tube_num));
|
|
||||||
|
|
||||||
_buffer[tube_num*2] = value >> 8;
|
|
||||||
_buffer[tube_num*2+1] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Seeed_Digital_Tube::setTubeBuf(TubeNum tube_num,char byte)
|
if (second_dot)
|
||||||
{
|
|
||||||
uint16_t value = disp_font_p[get_char_index(byte)];
|
|
||||||
|
|
||||||
if( TYPE_4 == _type )
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
_buffer[tube_num*2] = value;
|
|
||||||
_buffer[tube_num*2+1] = value >> 8;
|
|
||||||
replace_bit12(tube_num,value&0x02,value&0x04);
|
|
||||||
}
|
|
||||||
else if (TYPE_2 == _type)
|
|
||||||
{
|
|
||||||
if(false == isLegalToDisplay(byte))
|
|
||||||
{
|
{
|
||||||
|
_buffer[FIRST_TUBE * 2] |= disp_font_p[0] >> 8;
|
||||||
|
}
|
||||||
|
} else {}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Seeed_Digital_Tube::setTubeSegments(TubeNum tube_num, uint16_t segments) {
|
||||||
|
uint16_t value = 0;
|
||||||
|
|
||||||
|
if (TYPE_4 == _type) {
|
||||||
|
for (int i = 0; i < 16; i++) {
|
||||||
|
if (bitRead(segments, i) == 1) {
|
||||||
|
value += segments4Tubes[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_buffer[tube_num * 2] = value;
|
||||||
|
_buffer[tube_num * 2 + 1] = value >> 8;
|
||||||
|
replace_bit12(tube_num, value & 0x02, value & 0x04);
|
||||||
|
} else if (TYPE_2 == _type) {
|
||||||
|
for (int i = 0; i < 16; i++) {
|
||||||
|
if (bitRead(segments, i) == 1) {
|
||||||
|
value += segments2Tubes[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set tube_num to 1 if it's 2, and 2 if it's 1, so that it's compatible with the hardware.
|
||||||
|
tube_num = (TubeNum)(((int)tube_num + 1) & (~(int)tube_num));
|
||||||
|
|
||||||
|
_buffer[tube_num * 2] = value >> 8;
|
||||||
|
_buffer[tube_num * 2 + 1] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Seeed_Digital_Tube::setTubeBuf(TubeNum tube_num, char byte) {
|
||||||
|
uint16_t value = disp_font_p[get_char_index(byte)];
|
||||||
|
|
||||||
|
if (TYPE_4 == _type) {
|
||||||
|
|
||||||
|
|
||||||
|
_buffer[tube_num * 2] = value;
|
||||||
|
_buffer[tube_num * 2 + 1] = value >> 8;
|
||||||
|
replace_bit12(tube_num, value & 0x02, value & 0x04);
|
||||||
|
} else if (TYPE_2 == _type) {
|
||||||
|
if (false == isLegalToDisplay(byte)) {
|
||||||
byte = '/';
|
byte = '/';
|
||||||
}
|
}
|
||||||
//if first,set to 2,if second ,set to 1. To compatible with the hardware.
|
//if first,set to 2,if second ,set to 1. To compatible with the hardware.
|
||||||
tube_num = (TubeNum) (((int)tube_num+1) & (~(int)tube_num));
|
tube_num = (TubeNum)(((int)tube_num + 1) & (~(int)tube_num));
|
||||||
|
|
||||||
if(byte >= 'a' && byte <= 'z')
|
if (byte >= 'a' && byte <= 'z') {
|
||||||
{
|
|
||||||
byte -= 32;
|
byte -= 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((byte >='.' && byte <= '9'))
|
if ((byte >= '.' && byte <= '9')) {
|
||||||
{
|
_buffer[tube_num * 2] = disp_font_p[byte - '0' + 2] >> 8;
|
||||||
_buffer[tube_num*2] = disp_font_p[byte-'0'+2] >> 8;
|
_buffer[tube_num * 2 + 1] = disp_font_p[byte - '0' + 2];
|
||||||
_buffer[tube_num*2+1] = disp_font_p[byte-'0'+2];
|
} else {
|
||||||
}
|
_buffer[tube_num * 2] = disp_font_p[byte - 'A' + 10 + 2] >> 8;
|
||||||
else
|
_buffer[tube_num * 2 + 1] = disp_font_p[byte - 'A' + 10 + 2];
|
||||||
{
|
|
||||||
_buffer[tube_num*2] = disp_font_p[byte-'A'+10+2] >> 8;
|
|
||||||
_buffer[tube_num*2+1] = disp_font_p[byte-'A'+10+2];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**@brief Specify the display char of a digital tube.
|
/** @brief Specify the display char of a digital tube.
|
||||||
* @param tube_num The number of tube ,total 4.
|
@param tube_num The number of tube ,total 4.
|
||||||
* @param c ,The char to display
|
@param c ,The char to display
|
||||||
* */
|
* */
|
||||||
void Seeed_Digital_Tube::setTubeSingleChar(TubeNum tube_num,char c)
|
void Seeed_Digital_Tube::setTubeSingleChar(TubeNum tube_num, char c) {
|
||||||
{
|
if (!(((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z')) || (c == '.'))) {
|
||||||
if(!( ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z')) || (c=='.') ) )
|
|
||||||
{
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
if( TYPE_4 == _type )
|
if (TYPE_4 == _type) {
|
||||||
{
|
setTubeBuf(tube_num, c);
|
||||||
setTubeBuf(tube_num , c);
|
} else if (TYPE_2 == _type) {
|
||||||
}
|
if (tube_num > SECOND_TUBE) {
|
||||||
else if (TYPE_2 == _type)
|
|
||||||
{
|
|
||||||
if(tube_num > SECOND_TUBE)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setTubeBuf(tube_num ,c);
|
setTubeBuf(tube_num, c);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**@brief Specify the display number of a digital tube.
|
/** @brief Specify the display number of a digital tube.
|
||||||
* @param tube_num The number of tube ,total 4.
|
@param tube_num The number of tube ,total 4.
|
||||||
* @param num ,The number to display
|
@param num ,The number to display
|
||||||
* */
|
* */
|
||||||
void Seeed_Digital_Tube::setTubeSingleNum(TubeNum tube_num,char num)
|
void Seeed_Digital_Tube::setTubeSingleNum(TubeNum tube_num, char num) {
|
||||||
{
|
if (!((num >= 0) && (num <= 9))) {
|
||||||
if( !((num >= 0) && (num <= 9)) )
|
|
||||||
return ;
|
return ;
|
||||||
if( TYPE_4 == _type )
|
|
||||||
{
|
|
||||||
setTubeBuf(tube_num , num + 0x30);
|
|
||||||
}
|
}
|
||||||
else if (TYPE_2 == _type)
|
if (TYPE_4 == _type) {
|
||||||
{
|
setTubeBuf(tube_num, num + 0x30);
|
||||||
if(tube_num > SECOND_TUBE)
|
} else if (TYPE_2 == _type) {
|
||||||
|
if (tube_num > SECOND_TUBE) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setTubeBuf(tube_num ,num + 0x30);
|
setTubeBuf(tube_num, num + 0x30);
|
||||||
|
} else {
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Seeed_Digital_Tube::display_one_tube(TubeNum tube_num,uint16_t value)
|
void Seeed_Digital_Tube::display_one_tube(TubeNum tube_num, uint16_t value) {
|
||||||
{
|
_buffer[tube_num * 2] = value;
|
||||||
_buffer[tube_num*2] = value;
|
_buffer[tube_num * 2 + 1] = value >> 8;
|
||||||
_buffer[tube_num*2+1] = value >> 8;
|
replace_bit12(tube_num, value & 0x02, value & 0x04);
|
||||||
replace_bit12(tube_num,value&0x02,value&0x04);
|
|
||||||
writeBytes(_addr, 0x00, 16, _buffer);
|
writeBytes(_addr, 0x00, 16, _buffer);
|
||||||
delay(_ms);
|
delay(_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Seeed_Digital_Tube::clearBuf()
|
void Seeed_Digital_Tube::clearBuf() {
|
||||||
{
|
memset(_buffer, 0, sizeof(_buffer));
|
||||||
memset(_buffer,0,sizeof(_buffer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Seeed_Digital_Tube::get_char_index(char c)
|
int Seeed_Digital_Tube::get_char_index(char c) {
|
||||||
{
|
if ((c >= '0') && (c <= '9')) {
|
||||||
if((c >= '0') && (c <= '9'))
|
return c - 0x30 + 2;
|
||||||
{
|
} else if ((c >= 'A') && (c <= 'Z')) {
|
||||||
return c-0x30+2;
|
return c - 0x37 + 2;
|
||||||
}
|
} else if ((c >= 'a') && (c <= 'z')) {
|
||||||
else if((c >= 'A') && (c <= 'Z'))
|
return c - 0x57 + 2;
|
||||||
{
|
} else {
|
||||||
return c-0x37+2;
|
|
||||||
}
|
|
||||||
else if((c >= 'a') && (c <= 'z'))
|
|
||||||
{
|
|
||||||
return c-0x57+2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return LAST_ITEM;
|
return LAST_ITEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Seeed_Digital_Tube::display()
|
void Seeed_Digital_Tube::display() {
|
||||||
{
|
|
||||||
writeBytes(_addr, 0x00, 16, _buffer);
|
writeBytes(_addr, 0x00, 16, _buffer);
|
||||||
delay(_ms);
|
delay(_ms);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +1,40 @@
|
|||||||
/*
|
/*
|
||||||
* grove_alphanumeric_display.h
|
grove_alphanumeric_display.h
|
||||||
* A library for Grove - grove_alphanumeric_display
|
A library for Grove - grove_alphanumeric_display
|
||||||
*
|
|
||||||
* Copyright (c) 2018 seeed technology inc.
|
Copyright (c) 2018 seeed technology inc.
|
||||||
* Website : www.seeed.cc
|
Website : www.seeed.cc
|
||||||
* Author : Jerry Yip
|
Author : Jerry Yip
|
||||||
* Create Time: 2018-06
|
Create Time: 2018-06
|
||||||
* Version : 0.1
|
Version : 0.1
|
||||||
* Change Log :
|
Change Log :
|
||||||
* Copyright (c) 2018 seeed technology inc.
|
Copyright (c) 2018 seeed technology inc.
|
||||||
* Website : www.seeed.cc
|
Website : www.seeed.cc
|
||||||
* Author : downey
|
Author : downey
|
||||||
* Create Time: 2018-06
|
Create Time: 2018-06
|
||||||
* Version : 1.1
|
Version : 1.1
|
||||||
* Change Log :for digital tube development.
|
Change Log :for digital tube development.
|
||||||
*
|
|
||||||
* The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
* in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
* furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
The above copyright notice and this permission notice shall be included in
|
||||||
* all copies or substantial portions of the Software.
|
all copies or substantial portions of the Software.
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __GROVE_QUAD_ALPHANUMERIC_DISPLAY_H__
|
#ifndef __GROVE_QUAD_ALPHANUMERIC_DISPLAY_H__
|
||||||
#define __GROVE_QUAD_ALPHANUMERIC_DISPLAY_H__
|
#define __GROVE_QUAD_ALPHANUMERIC_DISPLAY_H__
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
#define TYPE_4_DEFAULT_I2C_ADDR 0x71
|
#define TYPE_4_DEFAULT_I2C_ADDR 0x71
|
||||||
#define TYPE_2_DEFAULT_I2C_ADDR 0x70
|
#define TYPE_2_DEFAULT_I2C_ADDR 0x70
|
||||||
|
|
||||||
#define MAX_BIG_BUFFER_SIZE (8*20)
|
#define MAX_BIG_BUFFER_SIZE (8*20)
|
||||||
|
|
||||||
#define MAX_TUBE_COUNT 4
|
#define MAX_TUBE_COUNT 4
|
||||||
|
|
||||||
@@ -83,95 +83,94 @@
|
|||||||
#define SEG_BRD 0x1000
|
#define SEG_BRD 0x1000
|
||||||
#define SEG_BV 0x2000
|
#define SEG_BV 0x2000
|
||||||
|
|
||||||
typedef enum
|
typedef enum {
|
||||||
{
|
|
||||||
FIRST_TUBE = 1,
|
FIRST_TUBE = 1,
|
||||||
SECOND_TUBE,
|
SECOND_TUBE,
|
||||||
THIRD_TUBE,
|
THIRD_TUBE,
|
||||||
FOURTH_TUBE,
|
FOURTH_TUBE,
|
||||||
}TubeNum;
|
} TubeNum;
|
||||||
|
|
||||||
typedef enum{
|
typedef enum {
|
||||||
TYPE_2,
|
TYPE_2,
|
||||||
TYPE_4,
|
TYPE_4,
|
||||||
}TubeType_t;
|
} TubeType_t;
|
||||||
|
|
||||||
|
|
||||||
typedef enum{
|
typedef enum {
|
||||||
CNT_2 = 2,
|
CNT_2 = 2,
|
||||||
CNT_4 = 4,
|
CNT_4 = 4,
|
||||||
}TubeCnt_t;
|
} TubeCnt_t;
|
||||||
|
|
||||||
class Seeed_Digital_Tube : public HT16K33 {
|
class Seeed_Digital_Tube : public HT16K33 {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Seeed_Digital_Tube();
|
Seeed_Digital_Tube();
|
||||||
|
|
||||||
void setTubeType(TubeType_t type,uint8_t addr = TYPE_2_DEFAULT_I2C_ADDR);
|
void setTubeType(TubeType_t type, uint8_t addr = TYPE_2_DEFAULT_I2C_ADDR);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
/**@brief Display number,If the param-num's len less than count of tubes(2 or 4),The tubes display static number,otherwise,it displays scroll number.
|
/** @brief Display number,If the param-num's len less than count of tubes(2 or 4),The tubes display static number,otherwise,it displays scroll number.
|
||||||
* When it displays scroll number,the param interval is scrolling interval(ms) ..
|
When it displays scroll number,the param interval is scrolling interval(ms) ..
|
||||||
* @param num the number to display.
|
@param num the number to display.
|
||||||
* @param interval :the interval of scroll number.
|
@param interval :the interval of scroll number.
|
||||||
* */
|
* */
|
||||||
void displayNum(uint32_t num,uint32_t interval = 0);
|
void displayNum(uint32_t num, uint32_t interval = 0);
|
||||||
|
|
||||||
/**@brief Display string,If the param-str's len less than count of tube(2 or 4),The tubes display static string,otherwise,it displays scroll string.
|
/** @brief Display string,If the param-str's len less than count of tube(2 or 4),The tubes display static string,otherwise,it displays scroll string.
|
||||||
* When it displays scroll string,the param interval is scrolling interval(ms) ..
|
When it displays scroll string,the param interval is scrolling interval(ms) ..
|
||||||
* @param str the str to display.
|
@param str the str to display.
|
||||||
* @param interval :the interval of scroll string.
|
@param interval :the interval of scroll string.
|
||||||
* */
|
* */
|
||||||
void displayString(char *str,uint32_t interval = 0);
|
void displayString(char* str, uint32_t interval = 0);
|
||||||
/**@brief Display all part of digital tube.
|
/** @brief Display all part of digital tube.
|
||||||
*
|
|
||||||
* */
|
* */
|
||||||
void fulDisplay();
|
void fulDisplay();
|
||||||
|
|
||||||
|
|
||||||
/**@brief Clear _buffer,just clear.
|
/** @brief Clear _buffer,just clear.
|
||||||
*
|
|
||||||
* */
|
* */
|
||||||
void clearBuf();
|
void clearBuf();
|
||||||
|
|
||||||
|
|
||||||
/**@brief Display the contents of _buffer.
|
/** @brief Display the contents of _buffer.
|
||||||
*
|
|
||||||
* */
|
* */
|
||||||
void display();
|
void display();
|
||||||
|
|
||||||
/**@brief Specify the display char of a digital tube.
|
/** @brief Specify the display char of a digital tube.
|
||||||
* @param tube_num The number of tube ,depend on the device you are using (max : 2 or 4).
|
@param tube_num The number of tube ,depend on the device you are using (max : 2 or 4).
|
||||||
* @param num ,The number to display
|
@param num ,The number to display
|
||||||
* */
|
* */
|
||||||
void setTubeSingleChar(TubeNum tube_num,char c);
|
void setTubeSingleChar(TubeNum tube_num, char c);
|
||||||
|
|
||||||
/**@brief Specify the display number of a digital tube.
|
/** @brief Specify the display number of a digital tube.
|
||||||
* @param tube_num The number of tube ,depend on the device you are using ( max : 2 or 4).
|
@param tube_num The number of tube ,depend on the device you are using ( max : 2 or 4).
|
||||||
* @param num ,The number to display
|
@param num ,The number to display
|
||||||
* */
|
* */
|
||||||
void setTubeSingleNum(TubeNum tube_num,char num);
|
void setTubeSingleNum(TubeNum tube_num, char num);
|
||||||
|
|
||||||
/**@brief Set two points status.
|
/** @brief Set two points status.
|
||||||
* @prarm upper_on if true,the first point light on ,otherwise turn off;
|
@prarm upper_on if true,the first point light on ,otherwise turn off;
|
||||||
* @prarm lower_on if true,the second point light on ,otherwise turn off;
|
@prarm lower_on if true,the second point light on ,otherwise turn off;
|
||||||
* */
|
* */
|
||||||
void setPoint(bool first_dot,bool second_dot);
|
void setPoint(bool first_dot, bool second_dot);
|
||||||
|
|
||||||
/**@brief Set the values of tube_num's segments.
|
/** @brief Set the values of tube_num's segments.
|
||||||
* @param tube_num The number of tube, depending on the device you are using (2 or 4).
|
@param tube_num The number of tube, depending on the device you are using (2 or 4).
|
||||||
* @prarm segments The segments that should be turned on.
|
@prarm segments The segments that should be turned on.
|
||||||
* */
|
* */
|
||||||
void setTubeSegments(TubeNum tube_num,uint16_t segments);
|
void setTubeSegments(TubeNum tube_num, uint16_t segments);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void display_one_tube(TubeNum tube_num,uint16_t value);
|
void display_one_tube(TubeNum tube_num, uint16_t value);
|
||||||
void replace_bit12(TubeNum tube_num,bool bit1,bool bit2);
|
void replace_bit12(TubeNum tube_num, bool bit1, bool bit2);
|
||||||
void setTubeBuf(TubeNum tube_num,char byte);
|
void setTubeBuf(TubeNum tube_num, char byte);
|
||||||
int get_char_index(char c);
|
int get_char_index(char c);
|
||||||
void shiftDisplay(char *origin_disp_buf,char new_item);
|
void shiftDisplay(char* origin_disp_buf, char new_item);
|
||||||
// Low1 High1 Low2 High2 ... Low8 High8
|
// Low1 High1 Low2 High2 ... Low8 High8
|
||||||
uint8_t _buffer[16];
|
uint8_t _buffer[16];
|
||||||
//uint8_t _big_buffer[MAX_BIG_BUFFER_SIZE];
|
//uint8_t _big_buffer[MAX_BIG_BUFFER_SIZE];
|
||||||
//uint16_t _cursor_start, _cursor_end, _cursor_steps;
|
//uint16_t _cursor_start, _cursor_end, _cursor_steps;
|
||||||
uint16_t _ms;
|
uint16_t _ms;
|
||||||
@@ -179,10 +178,10 @@ private:
|
|||||||
//int8_t _offset_x, _offset_y;
|
//int8_t _offset_x, _offset_y;
|
||||||
bool isLegalToDisplay(char byte);
|
bool isLegalToDisplay(char byte);
|
||||||
|
|
||||||
TubeType_t _type;
|
TubeType_t _type;
|
||||||
TubeCnt_t _tube_cnt;
|
TubeCnt_t _tube_cnt;
|
||||||
uint16_t *disp_font_p;
|
uint16_t* disp_font_p;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //__GROVE_LED_MATRIX_DRIVER_HT16K33__
|
#endif //__GROVE_LED_MATRIX_DRIVER_HT16K33__
|
||||||
Reference in New Issue
Block a user