Skip to content

Commit

Permalink
version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bakulaibuji committed Jul 2, 2021
1 parent 218d394 commit 669d636
Show file tree
Hide file tree
Showing 16 changed files with 1,381 additions and 0 deletions.
17 changes: 17 additions & 0 deletions LICENSE.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Copyright (c) DFRobot Corporation

All rights reserved.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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 THE SOFTWARE.
Binary file added arduinoC/_images/blocks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arduinoC/_images/example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added arduinoC/_images/featured.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions arduinoC/_images/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions arduinoC/_images/icon_backup.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions arduinoC/_locales/zh-cn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"led.ledConfig|block": "设置LED灯闪烁时间为[N]秒",
"led.ledStart|block": "LED灯开始闪烁",
"led.SIZE.1|menu": "29*29(1)",
"led.SIZE.2|menu": "58*58(2)"
}
67 changes: 67 additions & 0 deletions arduinoC/_menus/firebeetleesp32.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"PIN_AnalogWrite": {
"menu": [
["A0", "A0"],
["A1", "A1"],
["A2", "A2"],
["A3", "A3"],
["A4", "A4"]
]
},
"PIN_AnalogRead": {
"menu": [
["A0", "A0"],
["A1", "A1"],
["A2", "A2"],
["A3", "A3"],
["A4", "A4"]
]
},
"PIN_DigitalWrite": {
"menu": [
["D2", "D2"],
["D3", "D3"],
["D4", "D4"],
["D7", "D7"],
["D8", "D8"],
["D9", "D9"]
]
},
"PIN_DigitalRead": {
"menu": [
["D2", "D2"],
["D3", "D3"],
["D4", "D4"],
["D7", "D7"],
["D8", "D8"],
["D9", "D9"]
]
},
"PINMODE":{
"menu": [
["INPUT", "INPUT"],
["OUTPUT", "OUTPUT"],
["PULLUP", "PULLUP"],
["INPUT_PULLUP", "INPUT_PULLUP"],
["PULLDOWN", "PULLDOWN"],
["INPUT_PULLDOWN", "INPUT_PULLDOWN"],
["OPEN_DRAIN", "OPEN_DRAIN"],
["OUTPUT_OPEN_DRAIN", "OUTPUT_OPEN_DRAIN"],
["SPECIAL", "SPECIAL"]
]
},
"MODE":{
"menu":[
["LOOP","LOOP"],
["PASSWORD","PASSWORD"],
["BUTTON","BUTTON"]
]
}
,
"MICMODE":{
"menu":[
["MIC","MIC"],
["MONO","MONO"]
]
}
}
Binary file added arduinoC/libraries/libraries.zip
Binary file not shown.
86 changes: 86 additions & 0 deletions arduinoC/libraries/oled12864/oled12864.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include "oled12864.h"


OLED_12864::OLED_12864()
{

}

OLED_12864::~OLED_12864()
{

}

void OLED_12864::qrcode(uint32_t x, uint32_t y, const String& str, uint8_t scale)
{
QRCode qrcode;
uint8_t qrcodeData[qrcode_getBufferSize(3)];
uint8_t ex, ey;
uint8_t _brushWidth = brushWidth;
int16_t _brushColor = brushColor;
qrcode_initText(&qrcode, qrcodeData, 3, 0, str.c_str());
lineWidth(1);
for (uint8_t _y = 0; _y < qrcode.size; _y++) {
// Each horizontal module
for (uint8_t _x = 0; _x < qrcode.size; _x++) {
if(qrcode_getModule(&qrcode, _x, _y))
setBrushColor(1);
else
setBrushColor(0);
rect(_x*scale + x ,_y*scale + y, scale, scale);
ex = _x*scale + x + scale;
ey = _y*scale + y + scale;
}
Serial.print("\n");
}
regionalRefresh(x, y, ex-x+1, ey-y+1);
setBrushColor(_brushColor);
lineWidth(_brushWidth);
}

void OLED_12864::setLineWidth(uint32_t w)
{
lineWidth(w);
}

uint32_t OLED_12864::getLineWidth()
{
return brushWidth;
}

void OLED_12864::rect(int32_t x, int32_t y, int32_t width, int32_t height, bool fill)
{
int backspace = brushWidth/2 + brushWidth%2 - 1;
if(width < 0)
{
x += width;
width = -width;
}
if(height < 0)
{
y += height;
height = -height;
}
if(width == 0 && height == 0){
return;
}else if(width == 0){
for(int i=0; i<brushWidth; i++)
VLineOnePixel(x-backspace+i, y-backspace, height+backspace*2);
}else if(height == 0){
for(int i=0; i<brushWidth; i++)
HLineOnePixel(x-backspace, y-backspace+i, width+backspace*2);
}else if(fill){
for(int i=0; i<height+2*backspace; i++)
HLineOnePixel(x-backspace, y-backspace+i, width+backspace*2);
}else{
for(int i=0; i<brushWidth; i++)
HLineOnePixel(x-backspace, y-backspace+i, width+backspace*2);
for(int i=0; i<brushWidth; i++)
HLineOnePixel(x-backspace, y+height-1-brushWidth/2+i, width+backspace*2);
for(int i=0; i<brushWidth; i++)
VLineOnePixel(x-backspace+i, y-backspace, height+backspace*2);
for(int i=0; i<brushWidth; i++)
VLineOnePixel(x+width-1-brushWidth/2+i, y-backspace, height+backspace*2);
}
}

148 changes: 148 additions & 0 deletions arduinoC/libraries/oled12864/oled12864.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#ifndef _OLED12864_H
#define _OLED12864_H

#if ARDUINO < 100
#include <WProgram.h>
#else
#include <Arduino.h>
#endif

#include "Wire.h"
#include "qrcode.h"
#include "DFRobot_SSD1306.h"


#define SSD1306_I2CBEGIN() Wire.setClock(400000);


class OLED_12864 : public DFRobot_SSD1306
{
public:

OLED_12864();

~OLED_12864();

void qrcode(uint32_t x, uint32_t y, const String& str, uint8_t scale=2);

void setLineWidth(uint32_t w = 1);

uint32_t getLineWidth();

protected:

private:
void rect(int32_t x, int32_t y, int32_t width, int32_t height, bool fill = false);
/**
* @brief Set screen cache refresh range
*
* @param address: 8-bit I2C slave address [ addr | 0 ]
*
* @param reg: The address of the register in the device to write
*
* @param columnStart: Column start position
*
* @param columnEnd: End of column
*
* @param rowStart: Line start position
*
* @param rowEnd: End of line
*/
void setRefreshRange(int address, uint8_t reg, int columnStart, int columnEnd, int rowStart, int rowEnd)
{
#if defined(ESP_PLATFORM)
// send a bunch of data in one xmission
writeByte(address, reg, 0xB0 + rowStart);//set page address
writeByte(address, reg, (2+columnStart) & 0xf);//set lower column address
writeByte(address, reg, 0x10 | ((2+columnStart) >> 4));//set higher column address
#elif defined(NRF5)
// send a bunch of data in one xmission
writeByte(address, reg, SSD1306_COLUMNADDR);
writeByte(address, reg, columnStart);
writeByte(address, reg, columnEnd);
writeByte(address, reg, SSD1306_PAGEADDR);
writeByte(address, reg, rowStart);
writeByte(address, reg, rowEnd);
#else
#warning "This library only supports mpython and microbit"
#endif
}

/**
* @brief Write data to the register address in batches
*
* @param address: 8-bit I2C slave address [ addr | 0 ]
*
* @param reg: The address of the register in the device to write
*
* @param data: A pointer to a byte buffer containing the data to write
*
* @param length: The number of bytes to read
*
* @return Return the number of data
*/
int writeBuffer(int address, uint8_t reg, unsigned char *data, int length)
{
#if defined(ESP_PLATFORM)
int count=0;
SSD1306_I2CBEGIN();
Wire.beginTransmission(address);
Wire.write(reg);
while(count<length) {
Wire.write(*data);
data++;
count++;
}
Wire.endTransmission();
return count;
#elif defined(NRF5)
int count=0;
SSD1306_I2CBEGIN();
Wire.beginTransmission(address);
Wire.write(reg);
while(count<length) {
Wire.write(*data);
data++;
count++;
}
Wire.endTransmission();
return count;
#else
#warning "This library only supports mpython and microbit"
#endif
}

/**
* @brief Write a data to the register address
*
* @param address: 8-bit I2C slave address [ addr | 0 ]
*
* @param reg: The address of the register in the device to write.
*
* @param Data: to be written
*
* @return Return the number of data
*/
int writeByte(uint8_t address, uint8_t reg, uint8_t data)
{
#if defined(ESP_PLATFORM)
SSD1306_I2CBEGIN();
Wire.beginTransmission(address);
Wire.write(reg);
Wire.write(data);
Wire.endTransmission();
return 1;
#elif defined(NRF5)
SSD1306_I2CBEGIN();
Wire.beginTransmission(address);
Wire.write(reg);
Wire.write(data);
Wire.endTransmission();
return 1;
#else
#warning "This library only supports mpython and microbit"
#endif
}
};

#endif // _OLED12864_H
Loading

0 comments on commit 669d636

Please sign in to comment.