[Add] First commit

This commit is contained in:
2023-03-05 23:38:38 +08:00
commit d3d0304125
109 changed files with 4507 additions and 0 deletions

View File

@ -0,0 +1,5 @@
bmp280:bmp280.c bmp280.h
gcc -Wall bmp280.c -o bmp280 -lbcm2835 -lm
clean:
rm bmp280

View File

@ -0,0 +1,180 @@
#include <bcm2835.h>
#include <stdio.h>
#include <math.h>
#include "bmp280.h"
short dig_T2,dig_T3,dig_P2,dig_P3,dig_P4,dig_P5,dig_P6,dig_P7,dig_P8,dig_P9;
unsigned short dig_T1,dig_P1;
int t_fine;
/******************* BMP280 Driver Interface *****************************/
char I2C_readByte(char reg)
{
char buf[] = {reg};
bcm2835_i2c_read_register_rs(buf,buf,1);
return buf[0];
}
unsigned short I2C_readU16(char reg)
{
char buf[] = {reg,0};
bcm2835_i2c_read_register_rs(buf,buf,2);
int value = buf[1]*0x100+buf[0];
return value;
}
short I2C_readS16(char reg)
{
int result;
result = I2C_readU16(reg);
if (result > 32767)result -= 65536;
return (short)result;
}
void I2C_writeByte(char reg,char val)
{
char buf[] = {reg,val};
bcm2835_i2c_write(buf,2);
}
/******************* BMP280 operation functions *****************************/
void load_calibration()
{
/* read the temperature calibration parameters */
dig_T1 = I2C_readU16(BMP280_DIG_T1_LSB_REG);
dig_T2 = I2C_readS16(BMP280_DIG_T2_LSB_REG);
dig_T3 = I2C_readS16(BMP280_DIG_T3_LSB_REG);
/* read the pressure calibration parameters */
dig_P1 = I2C_readU16(BMP280_DIG_P1_LSB_REG);
dig_P2 = I2C_readS16(BMP280_DIG_P2_LSB_REG);
dig_P3 = I2C_readS16(BMP280_DIG_P3_LSB_REG);
dig_P4 = I2C_readS16(BMP280_DIG_P4_LSB_REG);
dig_P5 = I2C_readS16(BMP280_DIG_P5_LSB_REG);
dig_P6 = I2C_readS16(BMP280_DIG_P6_LSB_REG);
dig_P7 = I2C_readS16(BMP280_DIG_P7_LSB_REG);
dig_P8 = I2C_readS16(BMP280_DIG_P8_LSB_REG);
dig_P9 = I2C_readS16(BMP280_DIG_P9_LSB_REG);
/* printf("dig_T1 = %d\r\n",dig_T1);
printf("dig_T2 = %d\r\n",dig_T2);
printf("dig_T3 = %d\r\n",dig_T3);
printf("dig_P1 = %d\r\n",dig_P1);
printf("dig_P2 = %d\r\n",dig_P2);
printf("dig_P3 = %d\r\n",dig_P3);
printf("dig_P4 = %d\r\n",dig_P4);
printf("dig_P5 = %d\r\n",dig_P5);
printf("dig_P6 = %d\r\n",dig_P6);
printf("dig_P7 = %d\r\n",dig_P7);
printf("dig_P8 = %d\r\n",dig_P8);
printf("dig_P9 = %d\r\n",dig_P9);
*/
}
uint8_t BSP_BMP280_Init(void)
{
uint8_t id,ctrlmeas, config;
id = I2C_readByte(BMP280_ID_REG);
if(id == BMP280_ID_Value)
{
load_calibration();
ctrlmeas = 0xFF; //BMP280_T_MODE_1 << 5 | BMP280_P_MODE_1 << 2 | BMP280_SLEEP_MODE;
config = 0x14; //BMP280_T_SB1 << 5 | BMP280_FILTER_MODE_1 << 2;
I2C_writeByte(BMP280_CTRL_MEAS_REG, ctrlmeas);
I2C_writeByte(BMP280_CONFIG_REG, config);
return 0;
}
else
{
printf("Read BMP280 id error!\r\n");
return 1;
}
}
/* Returns temperature in DegC, double precision. Output value of "1.23"equals 51.23 DegC. */
double compensate_temperature(int32_t adc_T)
{
double var1, var2, temperature;
var1 = (((double) adc_T) / 16384.0 - ((double) dig_T1) / 1024.0) * ((double) dig_T2);
var2 = ((((double) adc_T) / 131072.0 - ((double) dig_T1) / 8192.0) * (((double) adc_T) / 131072.0
- ((double) dig_T1) / 8192.0)) * ((double) dig_T3);
t_fine = (int32_t) (var1 + var2);
temperature = (var1 + var2) / 5120.0;
return temperature;
}
/* Returns pressure in Pa as double. Output value of "6386.2"equals 96386.2 Pa = 963.862 hPa */
double compensate_pressure(int32_t adc_P)
{
double var1, var2, pressure;
var1 = ((double)t_fine / 2.0) - 64000.0;
var2 = var1 * var1 * ((double) dig_P6) / 32768.0;
var2 = var2 + var1 * ((double) dig_P5) * 2.0;
var2 = (var2 / 4.0) + (((double) dig_P4) * 65536.0);
var1 = (((double) dig_P3) * var1 * var1 / 524288.0 + ((double) dig_P2) * var1) / 524288.0;
var1 = (1.0 + var1 / 32768.0) * ((double) dig_P1);
if (var1 == 0.0) {
return 0; // avoid exception caused by division by zero
}
pressure = 1048576.0 - (double) adc_P;
pressure = (pressure - (var2 / 4096.0)) * 6250.0 / var1;
var1 = ((double) dig_P9) * pressure * pressure / 2147483648.0;
var2 = pressure * ((double) dig_P8) / 32768.0;
pressure = pressure + (var1 + var2 + ((double) dig_P7)) / 16.0;
return pressure;
}
/* Returns pressure in Pa as double. Output value of "6386.2"equals 96386.2 Pa = 963.862 hPa */
void get_temperature_and_pressure(double *temperature, double *pressure)
{
uint8_t lsb, msb, xlsb;
int32_t adc_P,adc_T;
xlsb = I2C_readByte(BMP280_TEMP_XLSB_REG);
lsb = I2C_readByte(BMP280_TEMP_LSB_REG);
msb = I2C_readByte(BMP280_TEMP_MSB_REG);
adc_T = (msb << 12) | (lsb << 4) | (xlsb >> 4);
* temperature = compensate_temperature(adc_T);
xlsb = I2C_readByte(BMP280_PRESS_XLSB_REG);
lsb = I2C_readByte(BMP280_PRESS_LSB_REG);
msb = I2C_readByte(BMP280_PRESS_MSB_REG);
adc_P = (msb << 12) | (lsb << 4) | (xlsb >> 4);
* pressure = compensate_pressure(adc_P);
}
int main(int argc,char **argv)
{
double temp,press;
printf("\nBMP180 Test Program ...\n");
if(!bcm2835_init()) return 1;
bcm2835_i2c_begin();
bcm2835_i2c_setSlaveAddress(BMP280_I2C_ADDRESS);
bcm2835_i2c_set_baudrate(10000);
BSP_BMP280_Init();
get_temperature_and_pressure(&temp,&press);
while(1)
{
bcm2835_delay(1000);
get_temperature_and_pressure(&temp,&press);
printf("Temperature = %.2f C Pressure = %.3f kPa \r\n",temp,press/1000);
}
printf("\n");
return 0;
}

View File

@ -0,0 +1,51 @@
#ifndef _BMP280_
#define _BMP280_
//i2c address
#define BMP280_I2C_ADDRESS 0x76 //SDO = 0
//Registers value
#define BMP280_ID_Value 0x58
#define BMP280_RESET_VALUE 0xB6
/* BMP280 Registers definition */
#define BMP280_TEMP_XLSB_REG 0xFC /*Temperature XLSB Register */
#define BMP280_TEMP_LSB_REG 0xFB /*Temperature LSB Register */
#define BMP280_TEMP_MSB_REG 0xFA /*Temperature LSB Register */
#define BMP280_PRESS_XLSB_REG 0xF9 /*Pressure XLSB Register */
#define BMP280_PRESS_LSB_REG 0xF8 /*Pressure LSB Register */
#define BMP280_PRESS_MSB_REG 0xF7 /*Pressure MSB Register */
#define BMP280_CONFIG_REG 0xF5 /*Configuration Register */
#define BMP280_CTRL_MEAS_REG 0xF4 /*Ctrl Measure Register */
#define BMP280_STATUS_REG 0xF3 /*Status Register */
#define BMP280_RESET_REG 0xE0 /*Softreset Register */
#define BMP280_ID_REG 0xD0 /*Chip ID Register */
/*calibration parameters */
#define BMP280_DIG_T1_LSB_REG 0x88
#define BMP280_DIG_T1_MSB_REG 0x89
#define BMP280_DIG_T2_LSB_REG 0x8A
#define BMP280_DIG_T2_MSB_REG 0x8B
#define BMP280_DIG_T3_LSB_REG 0x8C
#define BMP280_DIG_T3_MSB_REG 0x8D
#define BMP280_DIG_P1_LSB_REG 0x8E
#define BMP280_DIG_P1_MSB_REG 0x8F
#define BMP280_DIG_P2_LSB_REG 0x90
#define BMP280_DIG_P2_MSB_REG 0x91
#define BMP280_DIG_P3_LSB_REG 0x92
#define BMP280_DIG_P3_MSB_REG 0x93
#define BMP280_DIG_P4_LSB_REG 0x94
#define BMP280_DIG_P4_MSB_REG 0x95
#define BMP280_DIG_P5_LSB_REG 0x96
#define BMP280_DIG_P5_MSB_REG 0x97
#define BMP280_DIG_P6_LSB_REG 0x98
#define BMP280_DIG_P6_MSB_REG 0x99
#define BMP280_DIG_P7_LSB_REG 0x9A
#define BMP280_DIG_P7_MSB_REG 0x9B
#define BMP280_DIG_P8_LSB_REG 0x9C
#define BMP280_DIG_P8_MSB_REG 0x9D
#define BMP280_DIG_P9_LSB_REG 0x9E
#define BMP280_DIG_P9_MSB_REG 0x9F
#endif

View File

@ -0,0 +1,167 @@
import time
from smbus2 import SMBus
# BMP280 address.
BMP280_I2C_ADDRESS = 0x76 #SDO = 0
#Registers value
BMP280_ID_Value = 0x58
BMP280_RESET_VALUE = 0xB6
# BMP280 Registers definition
BMP280_TEMP_XLSB_REG = 0xFC #Temperature XLSB Register
BMP280_TEMP_LSB_REG = 0xFB #Temperature LSB Register
BMP280_TEMP_MSB_REG = 0xFA #Temperature LSB Register
BMP280_PRESS_XLSB_REG = 0xF9 #Pressure XLSB Register
BMP280_PRESS_LSB_REG = 0xF8 #Pressure LSB Register
BMP280_PRESS_MSB_REG = 0xF7 #Pressure MSB Register
BMP280_CONFIG_REG = 0xF5 #Configuration Register
BMP280_CTRL_MEAS_REG = 0xF4 #Ctrl Measure Register
BMP280_STATUS_REG = 0xF3 #Status Register
BMP280_RESET_REG = 0xE0 #Softreset Register
BMP280_ID_REG = 0xD0 #Chip ID Register
#calibration parameters
BMP280_DIG_T1_LSB_REG = 0x88
BMP280_DIG_T1_MSB_REG = 0x89
BMP280_DIG_T2_LSB_REG = 0x8A
BMP280_DIG_T2_MSB_REG = 0x8B
BMP280_DIG_T3_LSB_REG = 0x8C
BMP280_DIG_T3_MSB_REG = 0x8D
BMP280_DIG_P1_LSB_REG = 0x8E
BMP280_DIG_P1_MSB_REG = 0x8F
BMP280_DIG_P2_LSB_REG = 0x90
BMP280_DIG_P2_MSB_REG = 0x91
BMP280_DIG_P3_LSB_REG = 0x92
BMP280_DIG_P3_MSB_REG = 0x93
BMP280_DIG_P4_LSB_REG = 0x94
BMP280_DIG_P4_MSB_REG = 0x95
BMP280_DIG_P5_LSB_REG = 0x96
BMP280_DIG_P5_MSB_REG = 0x97
BMP280_DIG_P6_LSB_REG = 0x98
BMP280_DIG_P6_MSB_REG = 0x99
BMP280_DIG_P7_LSB_REG = 0x9A
BMP280_DIG_P7_MSB_REG = 0x9B
BMP280_DIG_P8_LSB_REG = 0x9C
BMP280_DIG_P8_MSB_REG = 0x9D
BMP280_DIG_P9_LSB_REG = 0x9E
BMP280_DIG_P9_MSB_REG = 0x9F
class BMP180(object):
def __init__(self, address=BMP280_I2C_ADDRESS):
self._address = address
self._bus = SMBus(1)
# Load calibration values.
if self._read_byte(BMP280_ID_REG) == BMP280_ID_Value:
self._load_calibration()
ctrlmeas = 0xFF #BMP280_T_MODE_1 << 5 | BMP280_P_MODE_1 << 2 | BMP280_SLEEP_MODE;
config = 0x14 #BMP280_T_SB1 << 5 | BMP280_FILTER_MODE_1 << 2;
self._write_byte(BMP280_CTRL_MEAS_REG, ctrlmeas);
self._write_byte(BMP280_CONFIG_REG, config)
else:
print("Read BMP280 id error!\r\n")
def _read_byte(self,cmd):
return self._bus.read_byte_data(self._address,cmd)
def _read_u16(self,cmd):
LSB = self._bus.read_byte_data(self._address,cmd)
MSB = self._bus.read_byte_data(self._address,cmd+1)
return (MSB << 8) + LSB
def _read_s16(self,cmd):
result = self._read_u16(cmd)
if result > 32767:result -= 65536
return result
def _write_byte(self,cmd,val):
self._bus.write_byte_data(self._address,cmd,val)
def _load_calibration(self):
"load calibration"
""" read the temperature calibration parameters """
self.dig_T1 =self._read_u16(BMP280_DIG_T1_LSB_REG)
self.dig_T2 =self._read_s16(BMP280_DIG_T2_LSB_REG)
self.dig_T3 =self._read_s16(BMP280_DIG_T3_LSB_REG)
""" read the pressure calibration parameters """
self.dig_P1 =self._read_u16(BMP280_DIG_P1_LSB_REG)
self.dig_P2 =self._read_s16(BMP280_DIG_P2_LSB_REG)
self.dig_P3 =self._read_s16(BMP280_DIG_P3_LSB_REG)
self.dig_P4 =self._read_s16(BMP280_DIG_P4_LSB_REG)
self.dig_P5 =self._read_s16(BMP280_DIG_P5_LSB_REG)
self.dig_P6 =self._read_s16(BMP280_DIG_P6_LSB_REG)
self.dig_P7 =self._read_s16(BMP280_DIG_P7_LSB_REG)
self.dig_P8 =self._read_s16(BMP280_DIG_P8_LSB_REG)
self.dig_P9 =self._read_s16(BMP280_DIG_P9_LSB_REG)
# print(self.dig_T1)
# print(self.dig_T2)
# print(self.dig_T3)
# print(self.dig_P1)
# print(self.dig_P2)
# print(self.dig_P3)
# print(self.dig_P4)
# print(self.dig_P5)
# print(self.dig_P6)
# print(self.dig_P7)
# print(self.dig_P8)
# print(self.dig_P9)
def compensate_temperature(self,adc_T):
"""Returns temperature in DegC, double precision. Output value of "1.23"equals 51.23 DegC."""
var1 = ((adc_T) / 16384.0 - (self.dig_T1) / 1024.0) * (self.dig_T2)
var2 = (((adc_T) / 131072.0 - (self.dig_T1) / 8192.0) * ((adc_T) / 131072.0 - (self.dig_T1) / 8192.0)) * (self.dig_T3)
self.t_fine = var1 + var2
temperature = (var1 + var2) / 5120.0
return temperature
def compensate_pressure(self,adc_P):
"""Returns pressure in Pa as double. Output value of "6386.2"equals 96386.2 Pa = 963.862 hPa."""
var1 = (self.t_fine / 2.0) - 64000.0
var2 = var1 * var1 * (self.dig_P6) / 32768.0
var2 = var2 + var1 * (self.dig_P5) * 2.0
var2 = (var2 / 4.0) + ((self.dig_P4) * 65536.0)
var1 = ((self.dig_P3) * var1 * var1 / 524288.0 + (self.dig_P2) * var1) / 524288.0
var1 = (1.0 + var1 / 32768.0) * (self.dig_P1)
if var1 == 0.0:
return 0 # avoid exception caused by division by zero
pressure = 1048576.0 - adc_P
pressure = (pressure - (var2 / 4096.0)) * 6250.0 / var1
var1 = (self.dig_P9) * pressure * pressure / 2147483648.0
var2 = pressure * (self.dig_P8) / 32768.0
pressure = pressure + (var1 + var2 + (self.dig_P7)) / 16.0
return pressure;
def get_temperature_and_pressure(self):
"""Returns pressure in Pa as double. Output value of "6386.2"equals 96386.2 Pa = 963.862 hPa."""
xlsb = self._read_byte(BMP280_TEMP_XLSB_REG)
lsb = self._read_byte(BMP280_TEMP_LSB_REG)
msb = self._read_byte(BMP280_TEMP_MSB_REG)
adc_T = (msb << 12) | (lsb << 4) | (xlsb >> 4)
temperature = self.compensate_temperature(adc_T)
xlsb = self._read_byte(BMP280_PRESS_XLSB_REG)
lsb = self._read_byte(BMP280_PRESS_LSB_REG)
msb = self._read_byte(BMP280_PRESS_MSB_REG)
adc_P = (msb << 12) | (lsb << 4) | (xlsb >> 4)
pressure = self.compensate_pressure(adc_P)
return temperature,pressure
if __name__ == '__main__':
import time
print("BMP280 Test Program ...\n")
bmp280 = BMP180()
while True:
time.sleep(1)
temperature,pressure = bmp280.get_temperature_and_pressure()
print(' Temperature = %.2f C Pressure = %.3f kPa'%(temperature,pressure/1000))

View File

@ -0,0 +1,5 @@
bmp280:bmp280.c bmp280.h
gcc -Wall bmp280.c -o bmp280 -lwiringPi -lm
clean:
rm bmp280

View File

@ -0,0 +1,175 @@
#include <wiringPi.h>
#include <wiringPiI2C.h>
#include <stdio.h>
#include <math.h>
#include "bmp280.h"
short dig_T2,dig_T3,dig_P2,dig_P3,dig_P4,dig_P5,dig_P6,dig_P7,dig_P8,dig_P9;
unsigned short dig_T1,dig_P1;
int t_fine;
int fd;
/******************* BMP280 Driver Interface *****************************/
char I2C_readByte(int reg)
{
return (char)wiringPiI2CReadReg8(fd,reg);
}
unsigned short I2C_readU16(int reg)
{
int MSB,LSB;
LSB = I2C_readByte(reg);
MSB = I2C_readByte(reg + 1);
int value = (MSB << 8) +LSB;
return (unsigned short)value;
}
short I2C_readS16(int reg)
{
int result;
result = I2C_readU16(reg);
if (result > 32767)result -= 65536;
return (short)result;
}
void I2C_writeByte(int reg,int val)
{
wiringPiI2CWriteReg8(fd,reg,val);
}
/******************* BMP280 operation functions *****************************/
void load_calibration()
{
/* read the temperature calibration parameters */
dig_T1 = I2C_readU16(BMP280_DIG_T1_LSB_REG);
dig_T2 = I2C_readS16(BMP280_DIG_T2_LSB_REG);
dig_T3 = I2C_readS16(BMP280_DIG_T3_LSB_REG);
/* read the pressure calibration parameters */
dig_P1 = I2C_readU16(BMP280_DIG_P1_LSB_REG);
dig_P2 = I2C_readS16(BMP280_DIG_P2_LSB_REG);
dig_P3 = I2C_readS16(BMP280_DIG_P3_LSB_REG);
dig_P4 = I2C_readS16(BMP280_DIG_P4_LSB_REG);
dig_P5 = I2C_readS16(BMP280_DIG_P5_LSB_REG);
dig_P6 = I2C_readS16(BMP280_DIG_P6_LSB_REG);
dig_P7 = I2C_readS16(BMP280_DIG_P7_LSB_REG);
dig_P8 = I2C_readS16(BMP280_DIG_P8_LSB_REG);
dig_P9 = I2C_readS16(BMP280_DIG_P9_LSB_REG);
printf("dig_T1 = %d\r\n",dig_T1);
printf("dig_T2 = %d\r\n",dig_T2);
printf("dig_T3 = %d\r\n",dig_T3);
printf("dig_P1 = %d\r\n",dig_P1);
printf("dig_P2 = %d\r\n",dig_P2);
printf("dig_P3 = %d\r\n",dig_P3);
printf("dig_P4 = %d\r\n",dig_P4);
printf("dig_P5 = %d\r\n",dig_P5);
printf("dig_P6 = %d\r\n",dig_P6);
printf("dig_P7 = %d\r\n",dig_P7);
printf("dig_P8 = %d\r\n",dig_P8);
printf("dig_P9 = %d\r\n",dig_P9);
}
unsigned char BSP_BMP280_Init(void)
{
unsigned char id,ctrlmeas, config;
id = I2C_readByte(BMP280_ID_REG);
if(id == BMP280_ID_Value)
{
load_calibration();
ctrlmeas = 0xFF; //BMP280_T_MODE_1 << 5 | BMP280_P_MODE_1 << 2 | BMP280_SLEEP_MODE;
config = 0x14; //BMP280_T_SB1 << 5 | BMP280_FILTER_MODE_1 << 2;
I2C_writeByte(BMP280_CTRL_MEAS_REG, ctrlmeas);
I2C_writeByte(BMP280_CONFIG_REG, config);
return 0;
}
else
{
printf("Read BMP280 id error!\r\n");
return 1;
}
}
/* Returns temperature in DegC, double precision. Output value of "1.23"equals 51.23 DegC. */
double compensate_temperature(int adc_T)
{
double var1, var2, temperature;
var1 = (((double) adc_T) / 16384.0 - ((double) dig_T1) / 1024.0) * ((double) dig_T2);
var2 = ((((double) adc_T) / 131072.0 - ((double) dig_T1) / 8192.0) * (((double) adc_T) / 131072.0
- ((double) dig_T1) / 8192.0)) * ((double) dig_T3);
t_fine = ( int) (var1 + var2);
temperature = (var1 + var2) / 5120.0;
return temperature;
}
/* Returns pressure in Pa as double. Output value of "6386.2"equals 96386.2 Pa = 963.862 hPa */
double compensate_pressure(int adc_P)
{
double var1, var2, pressure;
var1 = ((double)t_fine / 2.0) - 64000.0;
var2 = var1 * var1 * ((double) dig_P6) / 32768.0;
var2 = var2 + var1 * ((double) dig_P5) * 2.0;
var2 = (var2 / 4.0) + (((double) dig_P4) * 65536.0);
var1 = (((double) dig_P3) * var1 * var1 / 524288.0 + ((double) dig_P2) * var1) / 524288.0;
var1 = (1.0 + var1 / 32768.0) * ((double) dig_P1);
if (var1 == 0.0) {
return 0; // avoid exception caused by division by zero
}
pressure = 1048576.0 - (double) adc_P;
pressure = (pressure - (var2 / 4096.0)) * 6250.0 / var1;
var1 = ((double) dig_P9) * pressure * pressure / 2147483648.0;
var2 = pressure * ((double) dig_P8) / 32768.0;
pressure = pressure + (var1 + var2 + ((double) dig_P7)) / 16.0;
return pressure;
}
/* Returns pressure in Pa as double. Output value of "6386.2"equals 96386.2 Pa = 963.862 hPa */
void get_temperature_and_pressure(double *temperature, double *pressure)
{
unsigned char lsb, msb, xlsb;
int adc_P,adc_T;
xlsb = I2C_readByte(BMP280_TEMP_XLSB_REG);
lsb = I2C_readByte(BMP280_TEMP_LSB_REG);
msb = I2C_readByte(BMP280_TEMP_MSB_REG);
adc_T = (msb << 12) | (lsb << 4) | (xlsb >> 4);
//adc_T = 415148;
* temperature = compensate_temperature(adc_T);
xlsb = I2C_readByte(BMP280_PRESS_XLSB_REG);
lsb = I2C_readByte(BMP280_PRESS_LSB_REG);
msb = I2C_readByte(BMP280_PRESS_MSB_REG);
adc_P = (msb << 12) | (lsb << 4) | (xlsb >> 4);
//adc_P = 51988;
* pressure = compensate_pressure(adc_P);
}
int main(int argc,char **argv)
{
double temp,press;
printf("BMP180 Test Program ...\n");
if(wiringPiSetup() < 0) return 1;
fd = wiringPiI2CSetup(BMP280_I2C_ADDRESS);
load_calibration();
while(1)
{
get_temperature_and_pressure(&temp,&press);
printf("Temperature = %.2f C Pressure = %.3f kPa \r\n",temp,press/1000);
delay(1000);
}
return 0;
}

View File

@ -0,0 +1,50 @@
#ifndef _BMP280_
#define _BMP280_
//i2c address
#define BMP280_I2C_ADDRESS 0x76 //SDO = 0
//Registers value
#define BMP280_ID_Value 0x58
#define BMP280_RESET_VALUE 0xB6
/* BMP280 Registers definition */
#define BMP280_TEMP_XLSB_REG 0xFC /*Temperature XLSB Register */
#define BMP280_TEMP_LSB_REG 0xFB /*Temperature LSB Register */
#define BMP280_TEMP_MSB_REG 0xFA /*Temperature LSB Register */
#define BMP280_PRESS_XLSB_REG 0xF9 /*Pressure XLSB Register */
#define BMP280_PRESS_LSB_REG 0xF8 /*Pressure LSB Register */
#define BMP280_PRESS_MSB_REG 0xF7 /*Pressure MSB Register */
#define BMP280_CONFIG_REG 0xF5 /*Configuration Register */
#define BMP280_CTRL_MEAS_REG 0xF4 /*Ctrl Measure Register */
#define BMP280_STATUS_REG 0xF3 /*Status Register */
#define BMP280_RESET_REG 0xE0 /*Softreset Register */
#define BMP280_ID_REG 0xD0 /*Chip ID Register */
/*calibration parameters */
#define BMP280_DIG_T1_LSB_REG 0x88
#define BMP280_DIG_T1_MSB_REG 0x89
#define BMP280_DIG_T2_LSB_REG 0x8A
#define BMP280_DIG_T2_MSB_REG 0x8B
#define BMP280_DIG_T3_LSB_REG 0x8C
#define BMP280_DIG_T3_MSB_REG 0x8D
#define BMP280_DIG_P1_LSB_REG 0x8E
#define BMP280_DIG_P1_MSB_REG 0x8F
#define BMP280_DIG_P2_LSB_REG 0x90
#define BMP280_DIG_P2_MSB_REG 0x91
#define BMP280_DIG_P3_LSB_REG 0x92
#define BMP280_DIG_P3_MSB_REG 0x93
#define BMP280_DIG_P4_LSB_REG 0x94
#define BMP280_DIG_P4_MSB_REG 0x95
#define BMP280_DIG_P5_LSB_REG 0x96
#define BMP280_DIG_P5_MSB_REG 0x97
#define BMP280_DIG_P6_LSB_REG 0x98
#define BMP280_DIG_P6_MSB_REG 0x99
#define BMP280_DIG_P7_LSB_REG 0x9A
#define BMP280_DIG_P7_MSB_REG 0x9B
#define BMP280_DIG_P8_LSB_REG 0x9C
#define BMP280_DIG_P8_MSB_REG 0x9D
#define BMP280_DIG_P9_LSB_REG 0x9E
#define BMP280_DIG_P9_MSB_REG 0x9F
#endif

View File

@ -0,0 +1,5 @@
bmp180:ds18b20.c
gcc -Wall ds18b20.c -o ds18b20
clean:
rm ds18b20

View File

@ -0,0 +1,67 @@
/* ds18b20.c
* you can build this with something like:
* gcc -Wall ds18b20.c -o ds18b20
* sudo ./ds18b20
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
#include <string.h>
#include <time.h>
int main(int argc, char *argv[])
{
char path[50] = "/sys/bus/w1/devices/";
char rom[20];
char buf[100];
DIR *dirp;
struct dirent *direntp;
int fd =-1;
char *temp;
float value;
system("sudo modprobe w1-gpio");
system("sudo modprobe w1-therm");
if((dirp = opendir(path)) == NULL)
{
printf("opendir error\n");
return 1;
}
while((direntp = readdir(dirp)) != NULL)
{
if(strstr(direntp->d_name,"28-00000"))
{
strcpy(rom,direntp->d_name);
printf(" rom: %s\n",rom);
}
}
closedir(dirp);
strcat(path,rom);
strcat(path,"/w1_slave");
while(1)
{
if((fd = open(path,O_RDONLY)) < 0)
{
printf("open error\n");
return 1;
}
if(read(fd,buf,sizeof(buf)) < 0)
{
printf("read error\n");
return 1;
}
temp = strchr(buf,'t');
sscanf(temp,"t=%s",temp);
value = atof(temp)/1000;
printf(" temp : %3.3f °C\n",value);
sleep(1);
}
return 0;
}

View File

@ -0,0 +1,39 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
import os
import glob
import time
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
base_dir = '/sys/bus/w1/devices/'
device_folder = glob.glob(base_dir + '28*')[0]
device_file = device_folder + '/w1_slave'
def read_rom():
name_file=device_folder+'/name'
f = open(name_file,'r')
return f.readline()
def read_temp_raw():
f = open(device_file, 'r')
lines = f.readlines()
f.close()
return lines
def read_temp():
lines = read_temp_raw()
while lines[0].strip()[-3:] != 'YES':
time.sleep(0.2)
lines = read_temp_raw()
equals_pos = lines[1].find('t=')
if equals_pos != -1:
temp_string = lines[1][equals_pos+2:]
temp_c = float(temp_string) / 1000.0
temp_f = temp_c * 9.0 / 5.0 + 32.0
return temp_c, temp_f
print(' rom: '+ read_rom())
while True:
print(' C=%3.3f F=%3.3f'% read_temp())
time.sleep(1)

View File

@ -0,0 +1,5 @@
ds3231:ds3231.c
gcc -Wall ds3231.c -o ds3231 -lbcm2835
clean:
rm ds3231

View File

@ -0,0 +1,50 @@
#include <bcm2835.h>
#include <stdio.h>
#include <unistd.h>
//regaddr,seconds,minutes,hours,weekdays,days,months,yeas
char buf[]={0x00,0x00,0x47,0x11,0x05,0x19,0x06,0x15};
char *str[] ={"SUN","Mon","Tues","Wed","Thur","Fri","Sat"};
void pcf8563SetTime()
{
bcm2835_i2c_write(buf,8);
}
void pcf8563ReadTime()
{
buf[0] = 0x00;
bcm2835_i2c_write_read_rs(buf ,1, buf,7);
}
int main(int argc, char **argv)
{
if (!bcm2835_init())return 1;
bcm2835_i2c_begin();
bcm2835_i2c_setSlaveAddress(0x68);
bcm2835_i2c_set_baudrate(10000);
printf("DS3231 Test Program ...\n\n");
pcf8563SetTime();
while(1)
{
pcf8563ReadTime();
buf[0] = buf[0]&0x7F; //sec
buf[1] = buf[1]&0x7F; //min
buf[2] = buf[2]&0x3F; //hour
buf[3] = buf[3]&0x07; //week
buf[4] = buf[4]&0x3F; //day
buf[5] = buf[5]&0x1F; //mouth
//year/month/day
printf("20%02x/%02x/%02x ",buf[6],buf[5],buf[4]);
//hour:minute/second
printf("%02x:%02x:%02x ",buf[2],buf[1],buf[0]);
//weekday
printf("%s\n",str[(unsigned char)buf[3]]);
bcm2835_delay(1000);
}
bcm2835_i2c_end();
bcm2835_close();
return 0;
}

View File

@ -0,0 +1,29 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
import smbus
import time
address = 0x68
register = 0x00
#sec min hour week day mout year
NowTime = [0x00,0x00,0x18,0x04,0x12,0x08,0x15]
w = ["SUN","Mon","Tues","Wed","Thur","Fri","Sat"];
#/dev/i2c-1
bus = smbus.SMBus(1)
def ds3231SetTime():
bus.write_i2c_block_data(address,register,NowTime)
def ds3231ReadTime():
return bus.read_i2c_block_data(address,register,7);
ds3231SetTime()
while 1:
t = ds3231ReadTime()
t[0] = t[0]&0x7F #sec
t[1] = t[1]&0x7F #min
t[2] = t[2]&0x3F #hour
t[3] = t[3]&0x07 #week
t[4] = t[4]&0x3F #day
t[5] = t[5]&0x1F #mouth
print("20%x/%02x/%02x %02x:%02x:%02x %s" %(t[6],t[5],t[4],t[2],t[1],t[0],w[t[3]-1]))
time.sleep(1)

View File

@ -0,0 +1,5 @@
ds3231:ds3231.c
gcc -Wall ds3231.c -o ds3231 -lwiringPi
clean:
rm ds3231

View File

@ -0,0 +1,52 @@
#include <wiringPi.h>
#include <wiringPiI2C.h>
#include <stdio.h>
#define DS3231_Address 0x68
//seconds,minutes,hours,weekdays,days,months,yeas
char buf[]={0x00,0x47,0x11,0x05,0x19,0x06,0x15};
char *str[] ={"SUN","Mon","Tues","Wed","Thur","Fri","Sat"};
int fd,i;
void pcf8563SetTime()
{
for(i = 0;i < 7;i++)
{
wiringPiI2CWriteReg8(fd,i,buf[i]);
}
}
void pcf8563ReadTime()
{
for(i = 0;i < 7;i++)
{
buf[i] = (char)wiringPiI2CReadReg8(fd,i);
}
}
int main(int argc, char **argv)
{
if(wiringPiSetup() < 0)return 1;
fd = wiringPiI2CSetup(DS3231_Address);
printf("DS3231 Test Program ...\n\n");
pcf8563SetTime();
while(1)
{
pcf8563ReadTime();
buf[0] = buf[0]&0x7F; //sec
buf[1] = buf[1]&0x7F; //min
buf[2] = buf[2]&0x3F; //hour
buf[3] = buf[3]&0x07; //week
buf[4] = buf[4]&0x3F; //day
buf[5] = buf[5]&0x1F; //mouth
//year/month/day
printf("20%02x/%02x/%02x ",buf[6],buf[5],buf[4]);
//hour:minute/second
printf("%02x:%02x:%02x ",buf[2],buf[1],buf[0]);
//weekday
printf("%s\n",str[(unsigned char)buf[3]]);
delay(1000);
}
return 0;
}

View File

@ -0,0 +1,5 @@
irm:irm.c
gcc -Wall irm.c -o irm -lbcm2835
clean:
rm irm

View File

@ -0,0 +1,65 @@
// IRM
// After installing bcm2835, you can build this
// with something like:
// gcc -Wall IRM.c -o IRM -lbcm2835
// sudo ./IRM
#include <bcm2835.h>
#include <stdio.h>
#define PIN 18
#define IO bcm2835_gpio_lev(PIN)
unsigned char i,idx,cnt;
unsigned char count;
unsigned char data[4];
int main(int argc, char **argv)
{
if (!bcm2835_init())return 1;
bcm2835_gpio_fsel(PIN, BCM2835_GPIO_FSEL_INPT);
bcm2835_gpio_set_pud(PIN, BCM2835_GPIO_PUD_UP);
printf("IRM Test Program ... \n");
while (1)
{
if(IO == 0)
{
count = 0;
while(IO == 0 && count++ < 200) //9ms
delayMicroseconds(60);
count = 0;
while(IO == 1 && count++ < 80) //4.5ms
delayMicroseconds(60);
idx = 0;
cnt = 0;
data[0]=0;
data[1]=0;
data[2]=0;
data[3]=0;
for(i =0;i<32;i++)
{
count = 0;
while(IO == 0 && count++ < 15) //0.56ms
delayMicroseconds(60);
count = 0;
while(IO == 1 && count++ < 40) //0: 0.56ms; 1: 1.69ms
delayMicroseconds(60);
if (count > 25)data[idx] |= (1<<cnt);
if(cnt == 7)
{
cnt = 0;
idx++;
}
else cnt++;
}
if(data[0]+data[1] == 0xFF && data[2]+data[3]==0xFF) //check
printf("Get the key: 0x%02x\n",data[2]);
}
}
bcm2835_close();
return 0;
}

View File

@ -0,0 +1,48 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
import RPi.GPIO as GPIO
import time
PIN = 18;
GPIO.setmode(GPIO.BCM)
GPIO.setup(PIN,GPIO.IN,GPIO.PUD_UP)
print('IRM Test Start ...')
try:
while True:
if GPIO.input(PIN) == 0:
count = 0
while GPIO.input(PIN) == 0 and count < 200: #9ms
count += 1
time.sleep(0.00006)
count = 0
while GPIO.input(PIN) == 1 and count < 80: #4.5ms
count += 1
time.sleep(0.00006)
idx = 0
cnt = 0
data = [0,0,0,0]
for i in range(0,32):
count = 0
while GPIO.input(PIN) == 0 and count < 15: #0.56ms
count += 1
time.sleep(0.00006)
count = 0
while GPIO.input(PIN) == 1 and count < 40: #0: 0.56mx
count += 1 #1: 1.69ms
time.sleep(0.00006)
if count > 8:
data[idx] |= 1<<cnt
if cnt == 7:
cnt = 0
idx += 1
else:
cnt += 1
if data[0]+data[1] == 0xFF and data[2]+data[3] == 0xFF: #check
print("Get the key: 0x%02x" %data[2])
except KeyboardInterrupt:
GPIO.cleanup();

View File

@ -0,0 +1,5 @@
irm:irm.c
gcc -Wall irm.c -o irm -lwiringPi
clean:
rm irm

View File

@ -0,0 +1,57 @@
#include <wiringPi.h>
#include <stdio.h>
#define PIN 1
#define IO digitalRead(PIN)
unsigned char i,idx,cnt;
unsigned char count;
unsigned char data[4];
int main()
{
if (wiringPiSetup() < 0)return 1;
pinMode(PIN, INPUT);
pullUpDnControl(PIN, PUD_UP);
printf("IRM Test Program ... \n");
while (1)
{
if(IO == 0)
{
count = 0;
while(IO == 0 && count++ < 200) //9ms
delayMicroseconds(60);
count = 0;
while(IO == 1 && count++ < 80) //4.5ms
delayMicroseconds(60);
idx = 0;
cnt = 0;
data[0]=0;
data[1]=0;
data[2]=0;
data[3]=0;
for(i =0;i<32;i++)
{
count = 0;
while(IO == 0 && count++ < 15) //0.56ms
delayMicroseconds(60);
count = 0;
while(IO == 1 && count++ < 40) //0: 0.56ms; 1: 1.69ms
delayMicroseconds(60);
if (count > 25)data[idx] |= (1<<cnt);
if(cnt == 7)
{
cnt = 0;
idx++;
}
else cnt++;
}
if(data[0]+data[1] == 0xFF && data[2]+data[3]==0xFF) //check
printf("Get the key: 0x%02x\n",data[2]);
}
}
}

View File

@ -0,0 +1,6 @@
key:key.c
gcc -Wall key.c -o key -lbcm2835
gcc -Wall event.c -o event -lbcm2835
clean:
rm key event

View File

@ -0,0 +1,28 @@
/* key.c
* you can build this like:
* gcc -Wall key.c -o key -lbcm2835
* sudo ./key
*/
#include <bcm2835.h>
#include <stdio.h>
#define KEY 20
int main(int argc, char **argv)
{
if (!bcm2835_init())return 1;
bcm2835_gpio_fsel(KEY, BCM2835_GPIO_FSEL_INPT);
bcm2835_gpio_set_pud(KEY, BCM2835_GPIO_PUD_UP);
bcm2835_gpio_len(KEY);
printf("Key Test Program!!!!\n");
while (1)
{
if(bcm2835_gpio_eds(KEY))
{
bcm2835_gpio_set_eds(KEY);
printf("EVENT DETECT\n");
}
bcm2835_delay(500);
}
bcm2835_close();
return 0;
}

View File

@ -0,0 +1,29 @@
/* key.c
* you can build this like:
* gcc -Wall key.c -o key -lbcm2835
* sudo ./key
*/
#include <bcm2835.h>
#include <stdio.h>
char KEY = 20;
unsigned char i;
int main(int argc, char **argv)
{
if (!bcm2835_init())return 1;
bcm2835_gpio_fsel(KEY, BCM2835_GPIO_FSEL_INPT);
bcm2835_gpio_set_pud(KEY, BCM2835_GPIO_PUD_UP);
printf("Key Test Program!!!!\n");
while (1)
{
if(bcm2835_gpio_lev(KEY) == 0)
{
printf ("KEY PRESS\n") ;
while(bcm2835_gpio_lev(KEY) == 0)
bcm2835_delay(100);
}
bcm2835_delay(100);
}
bcm2835_close();
return 0;
}

View File

@ -0,0 +1,15 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
import RPi.GPIO as GPIO
import time
KEY = 20
def MyInterrupt(KEY):
print("KEY PRESS")
GPIO.setmode(GPIO.BCM)
GPIO.setup(KEY,GPIO.IN,GPIO.PUD_UP)
GPIO.add_event_detect(KEY,GPIO.FALLING,MyInterrupt,200)
while True:
time.sleep(1)

View File

@ -0,0 +1,16 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
import RPi.GPIO as GPIO
import time
KEY = 20
GPIO.setmode(GPIO.BCM)
GPIO.setup(KEY,GPIO.IN,GPIO.PUD_UP)
print("Key Test Program")
while True:
time.sleep(0.05)
if GPIO.input(KEY) == 0:
print("KEY PRESS")
while GPIO.input(KEY) == 0:
time.sleep(0.01)

View File

@ -0,0 +1,35 @@
/* Interrupt.c
* you can build this like:
* gcc -Wall Interrupt.c -o Interrupt -lwiringPi
* sudo ./Interrupt
*/
#include <stdio.h>
#include <wiringPi.h>
#define button 28
char flag = 0;
void myInterrupt()
{
flag ++;
}
int main()
{
if(wiringPiSetup() < 0)return 1;
pinMode(button,INPUT);
pullUpDnControl(button,PUD_UP);
if(wiringPiISR(button,INT_EDGE_RISING,&myInterrupt) < 0)
{
printf("Unable to setup ISR \n");
}
printf("Interrupt test program\n");
while(1)
{
if(flag)
{
while(digitalRead(button) ==0);
printf("button press\n");
flag = 0;
}
}
}

View File

@ -0,0 +1,6 @@
key:key.c
gcc -Wall key.c -o key -lwiringPi
gcc -Wall Interrupt.c -o Interrupt -lwiringPi
clean:
rm key Interrupt

View File

@ -0,0 +1,27 @@
/* key.c
* you can build this like:
* gcc -Wall key.c -o key -lwiringPi
* sudo ./key
*/
#include <stdio.h>
#include<wiringPi.h>
char KEY = 28;
int main()
{
if (wiringPiSetup() < 0)return 1 ;
pinMode (KEY,INPUT);
pullUpDnControl(KEY, PUD_UP);
printf("Key Test Program!!!\n");
while(1)
{
if (digitalRead(KEY) == 0)
{
printf ("KEY PRESS\n") ;
while(digitalRead(KEY) == 0)
delay(100);
}
delay(100);
}
}

View File

@ -0,0 +1,5 @@
led:led.c
gcc -Wall led.c -o led -lbcm2835
clean:
rm led

View File

@ -0,0 +1,23 @@
/* blink.c
* you can build this with something like:
* gcc -Wall blink.c -o blink -lbcm2835
* sudo ./blink
*/
#include <bcm2835.h>
#define PIN 26
int main(int argc, char **argv)
{
if (!bcm2835_init())return 1;
bcm2835_gpio_fsel(PIN, BCM2835_GPIO_FSEL_OUTP);
while (1)
{
bcm2835_gpio_write(PIN, HIGH);
bcm2835_delay(500);
bcm2835_gpio_write(PIN, LOW);
bcm2835_delay(500);
}
bcm2835_close();
return 0;
}

View File

@ -0,0 +1,5 @@
led:led.c
gcc led.c -o led
clean:
rm led

View File

@ -0,0 +1,138 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define IN 0
#define OUT 1
#define LOW 0
#define HIGH 1
#define POUT 26
#define BUFFER_MAX 3
#define DIRECTION_MAX 48
static int GPIOExport(int pin)
{
char buffer[BUFFER_MAX];
int len;
int fd;
fd = open("/sys/class/gpio/export", O_WRONLY);
if (fd < 0) {
fprintf(stderr, "Failed to open export for writing!\n");
return(-1);
}
len = snprintf(buffer, BUFFER_MAX, "%d", pin);
write(fd, buffer, len);
close(fd);
return(0);
}
static int GPIOUnexport(int pin)
{
char buffer[BUFFER_MAX];
int len;
int fd;
fd = open("/sys/class/gpio/unexport", O_WRONLY);
if (fd < 0) {
fprintf(stderr, "Failed to open unexport for writing!\n");
return(-1);
}
len = snprintf(buffer, BUFFER_MAX, "%d", pin);
write(fd, buffer, len);
close(fd);
return(0);
}
static int GPIODirection(int pin, int dir)
{
static const char dir_str[] = "in\0out";
char path[DIRECTION_MAX];
int fd;
snprintf(path, DIRECTION_MAX, "/sys/class/gpio/gpio%d/direction", pin);
fd = open(path, O_WRONLY);
if (fd < 0) {
fprintf(stderr, "failed to open gpio direction for writing!\n");
return(-1);
}
if (write(fd, &dir_str[dir == IN ? 0 : 3], dir == IN ? 2 : 3) < 0) {
fprintf(stderr, "failed to set direction!\n");
return(-1);
}
close(fd);
return(0);
}
static int GPIORead(int pin)
{
char path[DIRECTION_MAX];
char value_str[3];
int fd;
snprintf(path, DIRECTION_MAX, "/sys/class/gpio/gpio%d/value", pin);
fd = open(path, O_RDONLY);
if (fd < 0) {
fprintf(stderr, "failed to open gpio value for reading!\n");
return(-1);
}
if (read(fd, value_str, 3) < 0) {
fprintf(stderr, "failed to read value!\n");
return(-1);
}
close(fd);
return(atoi(value_str));
}
static int GPIOWrite(int pin, int value)
{
static const char s_values_str[] = "01";
char path[DIRECTION_MAX];
int fd;
snprintf(path, DIRECTION_MAX, "/sys/class/gpio/gpio%d/value", pin);
fd = open(path, O_WRONLY);
if (fd < 0) {
fprintf(stderr, "failed to open gpio value for writing!\n");
return(-1);
}
if (write(fd, &s_values_str[value == LOW ? 0 : 1], 1) < 0) {
fprintf(stderr, "failed to write value!\n");
return(-1);
}
close(fd);
return(0);
}
int main(int argc, char *argv[])
{
int i = 0;
GPIOExport(POUT);
GPIODirection(POUT, OUT);
for (i = 0; i < 20; i++) {
GPIOWrite(POUT, i % 2);
usleep(500 * 1000);
}
GPIOUnexport(POUT);
return(0);
}

View File

@ -0,0 +1,18 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
import RPi.GPIO as GPIO
import time
LED = 26
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED,GPIO.OUT)
try:
while True:
GPIO.output(LED,GPIO.HIGH)
time.sleep(1)
GPIO.output(LED,GPIO.LOW)
time.sleep(1)
except:
print("except")
GPIO.cleanup()

View File

@ -0,0 +1,22 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
import RPi.GPIO as GPIO
import time
LED = 26
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED,GPIO.OUT)
p = GPIO.PWM(LED,50)
p.start(0)
try:
while True:
for dc in range(0,101,5):
p.ChangeDutyCycle(dc)
time.sleep(0.05)
for dc in range(100,-1,-5):
p.ChangeDutyCycle(dc)
time.sleep(0.05)
except KeyboardInterrupt:
pass
p.stop()
GPIO.cleanup()

View File

@ -0,0 +1,9 @@
#! /bin/bash
#sudo ./LED.sh pin value
echo $1 > /sys/class/gpio/unexport
echo Exporting pin $1.
echo $1 > /sys/class/gpio/export
echo Setting direction to out.
echo out > /sys/class/gpio/gpio$1/direction
echo Setting pin $2
echo $2 > /sys/class/gpio/gpio$1/value

View File

@ -0,0 +1,6 @@
led:led.c
gcc -Wall led.c -o led -lwiringPi
gcc -Wall pwm.c -o pwm -lwiringPi
clean:
rm led pwm

View File

@ -0,0 +1,22 @@
/* blink.c
* you can build this like:
* gcc -Wall blink.c -o blink -lwiringPi
* sudo ./flash
*/
#include<wiringPi.h>
char LED = 25;
int main(void)
{
if(wiringPiSetup() < 0)return 1;
pinMode (LED,OUTPUT) ;
while(1)
{
digitalWrite(LED, 1) ;
delay (200);
digitalWrite(LED, 0) ;
delay (200);
}
}

View File

@ -0,0 +1,24 @@
/* Buzzer.c
* you can build this like:
* gcc -Wall Buzzer.c -o Buzzer -lwiringPi
* sudo ./Buzzer
*/
#include <stdio.h>
#include<wiringPi.h>
#include<softPwm.h>
int led = 25;
unsigned char i;
int main()
{
wiringPiSetup();
softPwmCreate(led,0,100);
while(1)
{
i += 5;
if (i > 100)i = 0;
softPwmWrite(led,i);
delay(200);
}
}

View File

@ -0,0 +1,8 @@
oled:oled.o SSD1306.o
gcc -Wall -o oled oled.o SSD1306.o -lbcm2835
SSD1306.o:SSD1306.c SSD1306.h
gcc -Wall -c SSD1306.c -lbcm2835
oled.o:oled.c SSD1306.h
gcc -Wall -c oled.c -lbcm2835
clean:
rm SSD1306.o oled.o oled

View File

@ -0,0 +1,193 @@
#include <bcm2835.h>
#include <stdio.h>
#include "SSD1306.h"
#define vccstate SSD1306_SWITCHCAPVCC
#define width 128
#define height 64
#define pages 8
#define RST 19
#define DC 16
char buffer[1024];
void command(char cmd){
bcm2835_gpio_write(DC,LOW);
bcm2835_spi_transfer(cmd);
}
void SSD1306_begin()
{
bcm2835_gpio_fsel(RST,BCM2835_GPIO_FSEL_OUTP);
bcm2835_gpio_fsel(DC,BCM2835_GPIO_FSEL_OUTP);
bcm2835_spi_begin();
bcm2835_spi_setBitOrder(BCM2835_SPI_BIT_ORDER_MSBFIRST); //The default
bcm2835_spi_setDataMode(BCM2835_SPI_MODE0); //The default
bcm2835_spi_setClockDivider(BCM2835_SPI_CLOCK_DIVIDER_256); //The default
bcm2835_spi_chipSelect(BCM2835_SPI_CS0); //The default
bcm2835_spi_setChipSelectPolarity(BCM2835_SPI_CS0, LOW); //the default
bcm2835_gpio_write(RST,HIGH);
bcm2835_delay(10);
bcm2835_gpio_write(RST,LOW);
bcm2835_delay(10);
bcm2835_gpio_write(RST,HIGH);
command(SSD1306_DISPLAYOFF);
command(SSD1306_SETDISPLAYCLOCKDIV);
command(0x80); // the suggested ratio 0x80
command(SSD1306_SETMULTIPLEX);
command(0x3F);
command(SSD1306_SETDISPLAYOFFSET);
command(0x0); // no offset
command(SSD1306_SETSTARTLINE | 0x0); // line #0
command(SSD1306_CHARGEPUMP);
command((vccstate == SSD1306_EXTERNALVCC) ? 0x10 : 0x14);
command(SSD1306_MEMORYMODE);
command(0x00); // 0x0 act like ks0108
command(SSD1306_SEGREMAP | 0x1);
command(SSD1306_COMSCANDEC);
command(SSD1306_SETCOMPINS);
command(0x12); // TODO - calculate based on _rawHieght ?
command(SSD1306_SETCONTRAST);
command((vccstate == SSD1306_EXTERNALVCC) ? 0x9F : 0xCF);
command(SSD1306_SETPRECHARGE);
command((vccstate == SSD1306_EXTERNALVCC) ? 0x22 : 0xF1);
command(SSD1306_SETVCOMDETECT);
command(0x40);
command(SSD1306_DISPLAYALLON_RESUME);
command(SSD1306_NORMALDISPLAY);
command(SSD1306_DISPLAYON);
}
void SSD1306_clear()
{
int i;
for(i = 0;i<sizeof(buffer);i++)
{
buffer[i] = 0;
}
}
void SSD1306_pixel(int x,int y,char color)
{
if(x > width || y > height)return ;
if(color)
buffer[x+(y/8)*width] |= 1<<(y%8);
else
buffer[x+(y/8)*width] &= ~(1<<(y%8));
}
void SSD1306_char1616(uint8_t x, uint8_t y, uint8_t chChar)
{
uint8_t i, j;
uint8_t chTemp = 0, y0 = y, chMode = 0;
for (i = 0; i < 32; i ++) {
chTemp = Font1612[chChar - 0x30][i];
for (j = 0; j < 8; j ++) {
chMode = chTemp & 0x80? 1 : 0;
SSD1306_pixel(x, y, chMode);
chTemp <<= 1;
y ++;
if ((y - y0) == 16) {
y = y0;
x ++;
break;
}
}
}
}
void SSD1306_char3216(uint8_t x, uint8_t y, uint8_t chChar)
{
uint8_t i, j;
uint8_t chTemp = 0, y0 = y, chMode = 0;
for (i = 0; i < 64; i ++) {
chTemp = Font3216[chChar - 0x30][i];
for (j = 0; j < 8; j ++) {
chMode = chTemp & 0x80? 1 : 0;
SSD1306_pixel(x, y, chMode);
chTemp <<= 1;
y ++;
if ((y - y0) == 32) {
y = y0;
x ++;
break;
}
}
}
}
void SSD1306_char(unsigned char x,unsigned char y,char acsii,char size,char mode)
{
unsigned char i,j,y0=y;
char temp;
unsigned char ch = acsii - ' ';
for(i = 0;i<size;i++)
{
if(size == 12)
{
if(mode)temp=Font1206[ch][i];
else temp = ~Font1206[ch][i];
}
else
{
if(mode)temp=Font1608[ch][i];
else temp = ~Font1608[ch][i];
}
for(j =0;j<8;j++)
{
if(temp & 0x80) SSD1306_pixel(x,y,1);
else SSD1306_pixel(x,y,0);
temp <<=1;
y++;
if((y-y0)==size)
{
y = y0;
x ++;
break;
}
}
}
}
void SSD1306_string(uint8_t x, uint8_t y, const char *pString, uint8_t Size, uint8_t Mode)
{
while (*pString != '\0') {
if (x > (width - Size / 2)) {
x = 0;
y += Size;
if (y > (height - Size)) {
y = x = 0;
}
}
SSD1306_char(x, y, *pString, Size, Mode);
x += Size / 2;
pString ++;
}
}
void SSD1306_bitmap(unsigned char x,unsigned char y,const unsigned char *pBmp,char chWidth,char chHeight)
{
unsigned char i,j,byteWidth = (chWidth + 7)/8;
for(j = 0;j < chHeight;j++){
for(i = 0;i <chWidth;i ++){
if(*(pBmp +j*byteWidth+i/8) & (128 >> (i & 7))){
SSD1306_pixel(x+i,y+j,1);
}
}
}
}
void SSD1306_display()
{
command(SSD1306_COLUMNADDR);
command(0); //cloumn start address
command(width -1); //cloumn end address
command(SSD1306_PAGEADDR);
command(0); //page atart address
command(pages -1); //page end address
bcm2835_gpio_write(DC,HIGH);
bcm2835_spi_transfern(buffer,sizeof(buffer));
}

View File

@ -0,0 +1,435 @@
#ifndef _SSD1306_H_
#define _SSD1306_H_
#define SSD1306_SETCONTRAST 0x81
#define SSD1306_DISPLAYALLON_RESUME 0xA4
#define SSD1306_DISPLAYALLON 0xA5
#define SSD1306_NORMALDISPLAY 0xA6
#define SSD1306_INVERTDISPLAY 0xA7
#define SSD1306_DISPLAYOFF 0xAE
#define SSD1306_DISPLAYON 0xAF
#define SSD1306_SETDISPLAYOFFSET 0xD3
#define SSD1306_SETCOMPINS 0xDA
#define SSD1306_SETVCOMDETECT 0xDB
#define SSD1306_SETDISPLAYCLOCKDIV 0xD5
#define SSD1306_SETPRECHARGE 0xD9
#define SSD1306_SETMULTIPLEX 0xA8
#define SSD1306_SETLOWCOLUMN 0x00
#define SSD1306_SETHIGHCOLUMN 0x10
#define SSD1306_SETSTARTLINE 0x40
#define SSD1306_MEMORYMODE 0x20
#define SSD1306_COLUMNADDR 0x21
#define SSD1306_PAGEADDR 0x22
#define SSD1306_COMSCANINC 0xC0
#define SSD1306_COMSCANDEC 0xC8
#define SSD1306_SEGREMAP 0xA0
#define SSD1306_CHARGEPUMP 0x8D
#define SSD1306_EXTERNALVCC 0x01
#define SSD1306_SWITCHCAPVCC 0x02
//Scrolling constants
#define SSD1306_ACTIVATE_SCROLL 0x2F
#define SSD1306_DEACTIVATE_SCROLL 0x2E
#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3
#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26
#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27
#define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29
#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A
void SSD1306_begin();
void SSD1306_display();
void SSD1306_clear();
void SSD1306_pixel(int x,int y,char color);
void SSD1306_bitmap(unsigned char x,unsigned char y,const unsigned char *pBmp,char chWidth,char chHeight);
void SSD1306_string(uint8_t x, uint8_t y, const char *pString, uint8_t Size, uint8_t Mode);
void SSD1306_char1616(uint8_t x, uint8_t y, uint8_t chChar);
void SSD1306_char3216(uint8_t x, uint8_t y, uint8_t chChar);
static const unsigned char waveshare[1024]=
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x11,0x11,0x00,0x9C,0x64,0x42,0x1C,0x78,0x7A,0x78,0xEF,0xB8,0x30,0x89,0x8C,0x70,
0x19,0x91,0x88,0x9C,0xF4,0x63,0x1E,0x78,0x7A,0x79,0xEF,0x3C,0x78,0x89,0x9E,0xF0,
0x09,0x91,0x88,0xB1,0x84,0x63,0x12,0x40,0x42,0x43,0x02,0x24,0xCC,0xC9,0x30,0x80,
0x09,0x91,0x88,0xB1,0x84,0x67,0x12,0x40,0x42,0x42,0x02,0x24,0x84,0xC9,0x20,0x80,
0x09,0x92,0x89,0xB0,0x84,0x65,0x12,0x40,0x42,0x42,0x02,0x24,0x84,0xC9,0x20,0xC0,
0x0A,0xB2,0x4D,0x1C,0xC7,0xE5,0x96,0x78,0x7A,0x72,0x02,0x2C,0x84,0xA9,0x20,0x60,
0x0A,0xA2,0x45,0x14,0x67,0xE4,0x9C,0x70,0x72,0x52,0x02,0x38,0x84,0xA9,0x20,0x30,
0x0A,0x63,0xC5,0x30,0x34,0x67,0x94,0x40,0x42,0x42,0x02,0x28,0x84,0xB9,0x20,0x10,
0x06,0x67,0xC7,0x30,0x14,0x6F,0x92,0x40,0x42,0x42,0x02,0x24,0x84,0x99,0x20,0x10,
0x06,0x64,0x66,0x30,0x14,0x68,0x92,0x40,0x42,0x43,0x02,0x24,0x8C,0x99,0x20,0x10,
0x06,0x64,0x22,0x3D,0xB4,0x68,0xD3,0x78,0x7A,0x79,0xE2,0x26,0x78,0x89,0xBE,0xF0,
0x04,0x44,0x22,0x1C,0xE4,0x48,0x51,0x78,0x7A,0x79,0xE2,0x22,0x70,0x89,0x9E,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3F,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3F,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3F,0xFF,0xFF,0x80,0x00,0x08,0x30,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
0x3F,0xFF,0xF7,0xC0,0x06,0xDB,0x30,0x3F,0xFF,0xFC,0x00,0x70,0x00,0x7F,0xFF,0xF0,
0x3F,0xFF,0xE7,0xE0,0x0E,0xDB,0x30,0x3F,0xFF,0xFC,0x7F,0xFF,0xF8,0x7F,0xFF,0xF0,
0x3F,0xFF,0xC7,0xF0,0x0C,0xDB,0x7E,0x00,0x18,0x00,0x7F,0xFF,0xF8,0x7F,0xFF,0xF0,
0x3F,0xFF,0x87,0xF0,0x1C,0xDB,0xFE,0x00,0x18,0x00,0x7F,0xFF,0xF8,0x00,0x00,0xF0,
0x3F,0xFF,0x07,0xF8,0x1C,0xDB,0xF0,0x3F,0xFF,0xFC,0x60,0x70,0x38,0x00,0x01,0xE0,
0x3F,0xFF,0x87,0xFC,0x18,0xDB,0xC0,0x3F,0xFF,0xF8,0x60,0x70,0x38,0x00,0x01,0xC0,
0x20,0xC3,0x86,0x3C,0x06,0xFF,0x00,0x30,0x18,0x18,0x60,0x70,0x38,0x00,0x03,0xC0,
0x30,0xC3,0x0C,0x3C,0x06,0xFF,0x0C,0x30,0x18,0x18,0x60,0x70,0x38,0x00,0x03,0x80,
0x30,0x43,0x0C,0x1E,0x0E,0xFF,0x6C,0x33,0x18,0xD8,0x60,0x70,0x38,0x07,0xFF,0x00,
0x30,0x00,0x1C,0x1E,0x0E,0x00,0x6C,0x33,0x9B,0xD8,0x70,0x70,0x38,0x07,0xFF,0x00,
0x38,0x00,0x08,0x0E,0x1C,0xFE,0x7C,0x30,0x18,0x18,0x7F,0xFF,0xF8,0x07,0xFE,0x00,
0x38,0x00,0x08,0x0E,0x1C,0xFE,0x3C,0x30,0x19,0x18,0x7F,0xFF,0xF8,0x07,0xFE,0x00,
0x38,0x00,0x00,0x06,0x1C,0xFE,0x38,0x31,0x9B,0x98,0x60,0x70,0x38,0x00,0x0E,0x00,
0x3C,0x10,0x00,0x86,0x0C,0x00,0x38,0x33,0x99,0xD8,0x60,0x70,0x38,0x00,0x0E,0x00,
0x3C,0x10,0x00,0x82,0x0C,0x00,0x38,0x00,0x00,0x00,0x60,0x70,0x38,0x00,0x0E,0x00,
0x3C,0x18,0x41,0x86,0x0C,0x7E,0x38,0x00,0x00,0x00,0x60,0x70,0x38,0xFF,0xFF,0xF0,
0x1E,0x38,0x41,0x86,0x0C,0x7E,0x18,0x3F,0xFF,0xF8,0x60,0x70,0x38,0xFF,0xFF,0xF0,
0x1E,0x38,0xE3,0x8E,0x0C,0x7E,0x18,0x3F,0xFF,0xF8,0x60,0x70,0x38,0xFF,0xFF,0xF0,
0x1E,0x7C,0xE2,0x0E,0x0C,0x66,0x38,0x00,0x00,0x18,0x7F,0xFF,0xF8,0x00,0x0E,0x00,
0x1F,0xFF,0xFE,0x1E,0x0C,0x66,0x38,0x00,0x00,0x18,0x7F,0xFF,0xF0,0x00,0x0E,0x00,
0x0F,0xFF,0xFE,0x0E,0x0C,0x66,0x38,0x1F,0xFF,0xF8,0x7F,0xFF,0xF0,0x00,0x0E,0x00,
0x0F,0xFF,0xFE,0x1E,0x0C,0x66,0x3C,0x1F,0xFF,0xF8,0x00,0x70,0x00,0x00,0x0E,0x00,
0x07,0xFF,0xFE,0x3E,0x0C,0x66,0x3C,0x10,0x00,0x38,0x00,0x70,0x00,0x00,0x0E,0x00,
0x03,0xFF,0xFE,0x7E,0x0C,0x66,0x7C,0x00,0x00,0x18,0x00,0x70,0x00,0x00,0x1E,0x00,
0x01,0xFF,0xFE,0xFE,0x0C,0xE7,0xEE,0x00,0x00,0x18,0x00,0x7F,0xF8,0x3F,0xFE,0x00,
0x00,0xFF,0xFF,0xFE,0x0C,0xE7,0xEE,0x3F,0xFF,0xF8,0x00,0x3F,0xF8,0x3F,0xFE,0x00,
0x00,0x7F,0xFF,0xFE,0x0C,0xC7,0xC6,0x3F,0xFF,0xF8,0x00,0x3F,0xF8,0x3F,0xFC,0x00,
0x00,0x1F,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static const uint8_t Font1206[95][12] = {
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/
{0x00,0x00,0x00,0x00,0x3F,0x40,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",1*/
{0x00,0x00,0x30,0x00,0x40,0x00,0x30,0x00,0x40,0x00,0x00,0x00},/*""",2*/
{0x09,0x00,0x0B,0xC0,0x3D,0x00,0x0B,0xC0,0x3D,0x00,0x09,0x00},/*"#",3*/
{0x18,0xC0,0x24,0x40,0x7F,0xE0,0x22,0x40,0x31,0x80,0x00,0x00},/*"$",4*/
{0x18,0x00,0x24,0xC0,0x1B,0x00,0x0D,0x80,0x32,0x40,0x01,0x80},/*"%",5*/
{0x03,0x80,0x1C,0x40,0x27,0x40,0x1C,0x80,0x07,0x40,0x00,0x40},/*"&",6*/
{0x10,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x80,0x20,0x40,0x40,0x20},/*"(",8*/
{0x00,0x00,0x40,0x20,0x20,0x40,0x1F,0x80,0x00,0x00,0x00,0x00},/*")",9*/
{0x09,0x00,0x06,0x00,0x1F,0x80,0x06,0x00,0x09,0x00,0x00,0x00},/*"*",10*/
{0x04,0x00,0x04,0x00,0x3F,0x80,0x04,0x00,0x04,0x00,0x00,0x00},/*"+",11*/
{0x00,0x10,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*",",12*/
{0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00},/*"-",13*/
{0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*".",14*/
{0x00,0x20,0x01,0xC0,0x06,0x00,0x38,0x00,0x40,0x00,0x00,0x00},/*"/",15*/
{0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"0",16*/
{0x00,0x00,0x10,0x40,0x3F,0xC0,0x00,0x40,0x00,0x00,0x00,0x00},/*"1",17*/
{0x18,0xC0,0x21,0x40,0x22,0x40,0x24,0x40,0x18,0x40,0x00,0x00},/*"2",18*/
{0x10,0x80,0x20,0x40,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"3",19*/
{0x02,0x00,0x0D,0x00,0x11,0x00,0x3F,0xC0,0x01,0x40,0x00,0x00},/*"4",20*/
{0x3C,0x80,0x24,0x40,0x24,0x40,0x24,0x40,0x23,0x80,0x00,0x00},/*"5",21*/
{0x1F,0x80,0x24,0x40,0x24,0x40,0x34,0x40,0x03,0x80,0x00,0x00},/*"6",22*/
{0x30,0x00,0x20,0x00,0x27,0xC0,0x38,0x00,0x20,0x00,0x00,0x00},/*"7",23*/
{0x1B,0x80,0x24,0x40,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"8",24*/
{0x1C,0x00,0x22,0xC0,0x22,0x40,0x22,0x40,0x1F,0x80,0x00,0x00},/*"9",25*/
{0x00,0x00,0x00,0x00,0x08,0x40,0x00,0x00,0x00,0x00,0x00,0x00},/*":",26*/
{0x00,0x00,0x00,0x00,0x04,0x60,0x00,0x00,0x00,0x00,0x00,0x00},/*";",27*/
{0x00,0x00,0x04,0x00,0x0A,0x00,0x11,0x00,0x20,0x80,0x40,0x40},/*"<",28*/
{0x09,0x00,0x09,0x00,0x09,0x00,0x09,0x00,0x09,0x00,0x00,0x00},/*"=",29*/
{0x00,0x00,0x40,0x40,0x20,0x80,0x11,0x00,0x0A,0x00,0x04,0x00},/*">",30*/
{0x18,0x00,0x20,0x00,0x23,0x40,0x24,0x00,0x18,0x00,0x00,0x00},/*"?",31*/
{0x1F,0x80,0x20,0x40,0x27,0x40,0x29,0x40,0x1F,0x40,0x00,0x00},/*"@",32*/
{0x00,0x40,0x07,0xC0,0x39,0x00,0x0F,0x00,0x01,0xC0,0x00,0x40},/*"A",33*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"B",34*/
{0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x30,0x80,0x00,0x00},/*"C",35*/
{0x20,0x40,0x3F,0xC0,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"D",36*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x2E,0x40,0x30,0xC0,0x00,0x00},/*"E",37*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x2E,0x00,0x30,0x00,0x00,0x00},/*"F",38*/
{0x0F,0x00,0x10,0x80,0x20,0x40,0x22,0x40,0x33,0x80,0x02,0x00},/*"G",39*/
{0x20,0x40,0x3F,0xC0,0x04,0x00,0x04,0x00,0x3F,0xC0,0x20,0x40},/*"H",40*/
{0x20,0x40,0x20,0x40,0x3F,0xC0,0x20,0x40,0x20,0x40,0x00,0x00},/*"I",41*/
{0x00,0x60,0x20,0x20,0x20,0x20,0x3F,0xC0,0x20,0x00,0x20,0x00},/*"J",42*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x0B,0x00,0x30,0xC0,0x20,0x40},/*"K",43*/
{0x20,0x40,0x3F,0xC0,0x20,0x40,0x00,0x40,0x00,0x40,0x00,0xC0},/*"L",44*/
{0x3F,0xC0,0x3C,0x00,0x03,0xC0,0x3C,0x00,0x3F,0xC0,0x00,0x00},/*"M",45*/
{0x20,0x40,0x3F,0xC0,0x0C,0x40,0x23,0x00,0x3F,0xC0,0x20,0x00},/*"N",46*/
{0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"O",47*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x24,0x00,0x18,0x00,0x00,0x00},/*"P",48*/
{0x1F,0x80,0x21,0x40,0x21,0x40,0x20,0xE0,0x1F,0xA0,0x00,0x00},/*"Q",49*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x26,0x00,0x19,0xC0,0x00,0x40},/*"R",50*/
{0x18,0xC0,0x24,0x40,0x24,0x40,0x22,0x40,0x31,0x80,0x00,0x00},/*"S",51*/
{0x30,0x00,0x20,0x40,0x3F,0xC0,0x20,0x40,0x30,0x00,0x00,0x00},/*"T",52*/
{0x20,0x00,0x3F,0x80,0x00,0x40,0x00,0x40,0x3F,0x80,0x20,0x00},/*"U",53*/
{0x20,0x00,0x3E,0x00,0x01,0xC0,0x07,0x00,0x38,0x00,0x20,0x00},/*"V",54*/
{0x38,0x00,0x07,0xC0,0x3C,0x00,0x07,0xC0,0x38,0x00,0x00,0x00},/*"W",55*/
{0x20,0x40,0x39,0xC0,0x06,0x00,0x39,0xC0,0x20,0x40,0x00,0x00},/*"X",56*/
{0x20,0x00,0x38,0x40,0x07,0xC0,0x38,0x40,0x20,0x00,0x00,0x00},/*"Y",57*/
{0x30,0x40,0x21,0xC0,0x26,0x40,0x38,0x40,0x20,0xC0,0x00,0x00},/*"Z",58*/
{0x00,0x00,0x00,0x00,0x7F,0xE0,0x40,0x20,0x40,0x20,0x00,0x00},/*"[",59*/
{0x00,0x00,0x70,0x00,0x0C,0x00,0x03,0x80,0x00,0x40,0x00,0x00},/*"\",60*/
{0x00,0x00,0x40,0x20,0x40,0x20,0x7F,0xE0,0x00,0x00,0x00,0x00},/*"]",61*/
{0x00,0x00,0x20,0x00,0x40,0x00,0x20,0x00,0x00,0x00,0x00,0x00},/*"^",62*/
{0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10},/*"_",63*/
{0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/
{0x00,0x00,0x02,0x80,0x05,0x40,0x05,0x40,0x03,0xC0,0x00,0x40},/*"a",65*/
{0x20,0x00,0x3F,0xC0,0x04,0x40,0x04,0x40,0x03,0x80,0x00,0x00},/*"b",66*/
{0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x40,0x06,0x40,0x00,0x00},/*"c",67*/
{0x00,0x00,0x03,0x80,0x04,0x40,0x24,0x40,0x3F,0xC0,0x00,0x40},/*"d",68*/
{0x00,0x00,0x03,0x80,0x05,0x40,0x05,0x40,0x03,0x40,0x00,0x00},/*"e",69*/
{0x00,0x00,0x04,0x40,0x1F,0xC0,0x24,0x40,0x24,0x40,0x20,0x00},/*"f",70*/
{0x00,0x00,0x02,0xE0,0x05,0x50,0x05,0x50,0x06,0x50,0x04,0x20},/*"g",71*/
{0x20,0x40,0x3F,0xC0,0x04,0x40,0x04,0x00,0x03,0xC0,0x00,0x40},/*"h",72*/
{0x00,0x00,0x04,0x40,0x27,0xC0,0x00,0x40,0x00,0x00,0x00,0x00},/*"i",73*/
{0x00,0x10,0x00,0x10,0x04,0x10,0x27,0xE0,0x00,0x00,0x00,0x00},/*"j",74*/
{0x20,0x40,0x3F,0xC0,0x01,0x40,0x07,0x00,0x04,0xC0,0x04,0x40},/*"k",75*/
{0x20,0x40,0x20,0x40,0x3F,0xC0,0x00,0x40,0x00,0x40,0x00,0x00},/*"l",76*/
{0x07,0xC0,0x04,0x00,0x07,0xC0,0x04,0x00,0x03,0xC0,0x00,0x00},/*"m",77*/
{0x04,0x40,0x07,0xC0,0x04,0x40,0x04,0x00,0x03,0xC0,0x00,0x40},/*"n",78*/
{0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x40,0x03,0x80,0x00,0x00},/*"o",79*/
{0x04,0x10,0x07,0xF0,0x04,0x50,0x04,0x40,0x03,0x80,0x00,0x00},/*"p",80*/
{0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x50,0x07,0xF0,0x00,0x10},/*"q",81*/
{0x04,0x40,0x07,0xC0,0x02,0x40,0x04,0x00,0x04,0x00,0x00,0x00},/*"r",82*/
{0x00,0x00,0x06,0x40,0x05,0x40,0x05,0x40,0x04,0xC0,0x00,0x00},/*"s",83*/
{0x00,0x00,0x04,0x00,0x1F,0x80,0x04,0x40,0x00,0x40,0x00,0x00},/*"t",84*/
{0x04,0x00,0x07,0x80,0x00,0x40,0x04,0x40,0x07,0xC0,0x00,0x40},/*"u",85*/
{0x04,0x00,0x07,0x00,0x04,0xC0,0x01,0x80,0x06,0x00,0x04,0x00},/*"v",86*/
{0x06,0x00,0x01,0xC0,0x07,0x00,0x01,0xC0,0x06,0x00,0x00,0x00},/*"w",87*/
{0x04,0x40,0x06,0xC0,0x01,0x00,0x06,0xC0,0x04,0x40,0x00,0x00},/*"x",88*/
{0x04,0x10,0x07,0x10,0x04,0xE0,0x01,0x80,0x06,0x00,0x04,0x00},/*"y",89*/
{0x00,0x00,0x04,0x40,0x05,0xC0,0x06,0x40,0x04,0x40,0x00,0x00},/*"z",90*/
{0x00,0x00,0x00,0x00,0x04,0x00,0x7B,0xE0,0x40,0x20,0x00,0x00},/*"{",91*/
{0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xF0,0x00,0x00,0x00,0x00},/*"|",92*/
{0x00,0x00,0x40,0x20,0x7B,0xE0,0x04,0x00,0x00,0x00,0x00,0x00},/*"}",93*/
{0x40,0x00,0x80,0x00,0x40,0x00,0x20,0x00,0x20,0x00,0x40,0x00},/*"~",94*/
};
static const uint8_t Font1608[95][16] = {
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xCC,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",1*/
{0x00,0x00,0x08,0x00,0x30,0x00,0x60,0x00,0x08,0x00,0x30,0x00,0x60,0x00,0x00,0x00},/*""",2*/
{0x02,0x20,0x03,0xFC,0x1E,0x20,0x02,0x20,0x03,0xFC,0x1E,0x20,0x02,0x20,0x00,0x00},/*"#",3*/
{0x00,0x00,0x0E,0x18,0x11,0x04,0x3F,0xFF,0x10,0x84,0x0C,0x78,0x00,0x00,0x00,0x00},/*"$",4*/
{0x0F,0x00,0x10,0x84,0x0F,0x38,0x00,0xC0,0x07,0x78,0x18,0x84,0x00,0x78,0x00,0x00},/*"%",5*/
{0x00,0x78,0x0F,0x84,0x10,0xC4,0x11,0x24,0x0E,0x98,0x00,0xE4,0x00,0x84,0x00,0x08},/*"&",6*/
{0x08,0x00,0x68,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x18,0x18,0x20,0x04,0x40,0x02,0x00,0x00},/*"(",8*/
{0x00,0x00,0x40,0x02,0x20,0x04,0x18,0x18,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00},/*")",9*/
{0x02,0x40,0x02,0x40,0x01,0x80,0x0F,0xF0,0x01,0x80,0x02,0x40,0x02,0x40,0x00,0x00},/*"*",10*/
{0x00,0x80,0x00,0x80,0x00,0x80,0x0F,0xF8,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x00},/*"+",11*/
{0x00,0x01,0x00,0x0D,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*",",12*/
{0x00,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80},/*"-",13*/
{0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*".",14*/
{0x00,0x00,0x00,0x06,0x00,0x18,0x00,0x60,0x01,0x80,0x06,0x00,0x18,0x00,0x20,0x00},/*"/",15*/
{0x00,0x00,0x07,0xF0,0x08,0x08,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"0",16*/
{0x00,0x00,0x08,0x04,0x08,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"1",17*/
{0x00,0x00,0x0E,0x0C,0x10,0x14,0x10,0x24,0x10,0x44,0x11,0x84,0x0E,0x0C,0x00,0x00},/*"2",18*/
{0x00,0x00,0x0C,0x18,0x10,0x04,0x11,0x04,0x11,0x04,0x12,0x88,0x0C,0x70,0x00,0x00},/*"3",19*/
{0x00,0x00,0x00,0xE0,0x03,0x20,0x04,0x24,0x08,0x24,0x1F,0xFC,0x00,0x24,0x00,0x00},/*"4",20*/
{0x00,0x00,0x1F,0x98,0x10,0x84,0x11,0x04,0x11,0x04,0x10,0x88,0x10,0x70,0x00,0x00},/*"5",21*/
{0x00,0x00,0x07,0xF0,0x08,0x88,0x11,0x04,0x11,0x04,0x18,0x88,0x00,0x70,0x00,0x00},/*"6",22*/
{0x00,0x00,0x1C,0x00,0x10,0x00,0x10,0xFC,0x13,0x00,0x1C,0x00,0x10,0x00,0x00,0x00},/*"7",23*/
{0x00,0x00,0x0E,0x38,0x11,0x44,0x10,0x84,0x10,0x84,0x11,0x44,0x0E,0x38,0x00,0x00},/*"8",24*/
{0x00,0x00,0x07,0x00,0x08,0x8C,0x10,0x44,0x10,0x44,0x08,0x88,0x07,0xF0,0x00,0x00},/*"9",25*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x03,0x0C,0x00,0x00,0x00,0x00,0x00,0x00},/*":",26*/
{0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*";",27*/
{0x00,0x00,0x00,0x80,0x01,0x40,0x02,0x20,0x04,0x10,0x08,0x08,0x10,0x04,0x00,0x00},/*"<",28*/
{0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x00,0x00},/*"=",29*/
{0x00,0x00,0x10,0x04,0x08,0x08,0x04,0x10,0x02,0x20,0x01,0x40,0x00,0x80,0x00,0x00},/*">",30*/
{0x00,0x00,0x0E,0x00,0x12,0x00,0x10,0x0C,0x10,0x6C,0x10,0x80,0x0F,0x00,0x00,0x00},/*"?",31*/
{0x03,0xE0,0x0C,0x18,0x13,0xE4,0x14,0x24,0x17,0xC4,0x08,0x28,0x07,0xD0,0x00,0x00},/*"@",32*/
{0x00,0x04,0x00,0x3C,0x03,0xC4,0x1C,0x40,0x07,0x40,0x00,0xE4,0x00,0x1C,0x00,0x04},/*"A",33*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x04,0x11,0x04,0x0E,0x88,0x00,0x70,0x00,0x00},/*"B",34*/
{0x03,0xE0,0x0C,0x18,0x10,0x04,0x10,0x04,0x10,0x04,0x10,0x08,0x1C,0x10,0x00,0x00},/*"C",35*/
{0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"D",36*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x04,0x17,0xC4,0x10,0x04,0x08,0x18,0x00,0x00},/*"E",37*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x00,0x17,0xC0,0x10,0x00,0x08,0x00,0x00,0x00},/*"F",38*/
{0x03,0xE0,0x0C,0x18,0x10,0x04,0x10,0x04,0x10,0x44,0x1C,0x78,0x00,0x40,0x00,0x00},/*"G",39*/
{0x10,0x04,0x1F,0xFC,0x10,0x84,0x00,0x80,0x00,0x80,0x10,0x84,0x1F,0xFC,0x10,0x04},/*"H",40*/
{0x00,0x00,0x10,0x04,0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x04,0x00,0x00,0x00,0x00},/*"I",41*/
{0x00,0x03,0x00,0x01,0x10,0x01,0x10,0x01,0x1F,0xFE,0x10,0x00,0x10,0x00,0x00,0x00},/*"J",42*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x03,0x80,0x14,0x64,0x18,0x1C,0x10,0x04,0x00,0x00},/*"K",43*/
{0x10,0x04,0x1F,0xFC,0x10,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x0C,0x00,0x00},/*"L",44*/
{0x10,0x04,0x1F,0xFC,0x1F,0x00,0x00,0xFC,0x1F,0x00,0x1F,0xFC,0x10,0x04,0x00,0x00},/*"M",45*/
{0x10,0x04,0x1F,0xFC,0x0C,0x04,0x03,0x00,0x00,0xE0,0x10,0x18,0x1F,0xFC,0x10,0x00},/*"N",46*/
{0x07,0xF0,0x08,0x08,0x10,0x04,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"O",47*/
{0x10,0x04,0x1F,0xFC,0x10,0x84,0x10,0x80,0x10,0x80,0x10,0x80,0x0F,0x00,0x00,0x00},/*"P",48*/
{0x07,0xF0,0x08,0x18,0x10,0x24,0x10,0x24,0x10,0x1C,0x08,0x0A,0x07,0xF2,0x00,0x00},/*"Q",49*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x00,0x11,0xC0,0x11,0x30,0x0E,0x0C,0x00,0x04},/*"R",50*/
{0x00,0x00,0x0E,0x1C,0x11,0x04,0x10,0x84,0x10,0x84,0x10,0x44,0x1C,0x38,0x00,0x00},/*"S",51*/
{0x18,0x00,0x10,0x00,0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x00,0x18,0x00,0x00,0x00},/*"T",52*/
{0x10,0x00,0x1F,0xF8,0x10,0x04,0x00,0x04,0x00,0x04,0x10,0x04,0x1F,0xF8,0x10,0x00},/*"U",53*/
{0x10,0x00,0x1E,0x00,0x11,0xE0,0x00,0x1C,0x00,0x70,0x13,0x80,0x1C,0x00,0x10,0x00},/*"V",54*/
{0x1F,0xC0,0x10,0x3C,0x00,0xE0,0x1F,0x00,0x00,0xE0,0x10,0x3C,0x1F,0xC0,0x00,0x00},/*"W",55*/
{0x10,0x04,0x18,0x0C,0x16,0x34,0x01,0xC0,0x01,0xC0,0x16,0x34,0x18,0x0C,0x10,0x04},/*"X",56*/
{0x10,0x00,0x1C,0x00,0x13,0x04,0x00,0xFC,0x13,0x04,0x1C,0x00,0x10,0x00,0x00,0x00},/*"Y",57*/
{0x08,0x04,0x10,0x1C,0x10,0x64,0x10,0x84,0x13,0x04,0x1C,0x04,0x10,0x18,0x00,0x00},/*"Z",58*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFE,0x40,0x02,0x40,0x02,0x40,0x02,0x00,0x00},/*"[",59*/
{0x00,0x00,0x30,0x00,0x0C,0x00,0x03,0x80,0x00,0x60,0x00,0x1C,0x00,0x03,0x00,0x00},/*"\",60*/
{0x00,0x00,0x40,0x02,0x40,0x02,0x40,0x02,0x7F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00},/*"]",61*/
{0x00,0x00,0x00,0x00,0x20,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x00,0x00},/*"^",62*/
{0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01},/*"_",63*/
{0x00,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/
{0x00,0x00,0x00,0x98,0x01,0x24,0x01,0x44,0x01,0x44,0x01,0x44,0x00,0xFC,0x00,0x04},/*"a",65*/
{0x10,0x00,0x1F,0xFC,0x00,0x88,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x70,0x00,0x00},/*"b",66*/
{0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x00},/*"c",67*/
{0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x11,0x08,0x1F,0xFC,0x00,0x04},/*"d",68*/
{0x00,0x00,0x00,0xF8,0x01,0x44,0x01,0x44,0x01,0x44,0x01,0x44,0x00,0xC8,0x00,0x00},/*"e",69*/
{0x00,0x00,0x01,0x04,0x01,0x04,0x0F,0xFC,0x11,0x04,0x11,0x04,0x11,0x00,0x18,0x00},/*"f",70*/
{0x00,0x00,0x00,0xD6,0x01,0x29,0x01,0x29,0x01,0x29,0x01,0xC9,0x01,0x06,0x00,0x00},/*"g",71*/
{0x10,0x04,0x1F,0xFC,0x00,0x84,0x01,0x00,0x01,0x00,0x01,0x04,0x00,0xFC,0x00,0x04},/*"h",72*/
{0x00,0x00,0x01,0x04,0x19,0x04,0x19,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"i",73*/
{0x00,0x00,0x00,0x03,0x00,0x01,0x01,0x01,0x19,0x01,0x19,0xFE,0x00,0x00,0x00,0x00},/*"j",74*/
{0x10,0x04,0x1F,0xFC,0x00,0x24,0x00,0x40,0x01,0xB4,0x01,0x0C,0x01,0x04,0x00,0x00},/*"k",75*/
{0x00,0x00,0x10,0x04,0x10,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"l",76*/
{0x01,0x04,0x01,0xFC,0x01,0x04,0x01,0x00,0x01,0xFC,0x01,0x04,0x01,0x00,0x00,0xFC},/*"m",77*/
{0x01,0x04,0x01,0xFC,0x00,0x84,0x01,0x00,0x01,0x00,0x01,0x04,0x00,0xFC,0x00,0x04},/*"n",78*/
{0x00,0x00,0x00,0xF8,0x01,0x04,0x01,0x04,0x01,0x04,0x01,0x04,0x00,0xF8,0x00,0x00},/*"o",79*/
{0x01,0x01,0x01,0xFF,0x00,0x85,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x70,0x00,0x00},/*"p",80*/
{0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x01,0x05,0x01,0xFF,0x00,0x01},/*"q",81*/
{0x01,0x04,0x01,0x04,0x01,0xFC,0x00,0x84,0x01,0x04,0x01,0x00,0x01,0x80,0x00,0x00},/*"r",82*/
{0x00,0x00,0x00,0xCC,0x01,0x24,0x01,0x24,0x01,0x24,0x01,0x24,0x01,0x98,0x00,0x00},/*"s",83*/
{0x00,0x00,0x01,0x00,0x01,0x00,0x07,0xF8,0x01,0x04,0x01,0x04,0x00,0x00,0x00,0x00},/*"t",84*/
{0x01,0x00,0x01,0xF8,0x00,0x04,0x00,0x04,0x00,0x04,0x01,0x08,0x01,0xFC,0x00,0x04},/*"u",85*/
{0x01,0x00,0x01,0x80,0x01,0x70,0x00,0x0C,0x00,0x10,0x01,0x60,0x01,0x80,0x01,0x00},/*"v",86*/
{0x01,0xF0,0x01,0x0C,0x00,0x30,0x01,0xC0,0x00,0x30,0x01,0x0C,0x01,0xF0,0x01,0x00},/*"w",87*/
{0x00,0x00,0x01,0x04,0x01,0x8C,0x00,0x74,0x01,0x70,0x01,0x8C,0x01,0x04,0x00,0x00},/*"x",88*/
{0x01,0x01,0x01,0x81,0x01,0x71,0x00,0x0E,0x00,0x18,0x01,0x60,0x01,0x80,0x01,0x00},/*"y",89*/
{0x00,0x00,0x01,0x84,0x01,0x0C,0x01,0x34,0x01,0x44,0x01,0x84,0x01,0x0C,0x00,0x00},/*"z",90*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x3E,0xFC,0x40,0x02,0x40,0x02},/*"{",91*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00},/*"|",92*/
{0x00,0x00,0x40,0x02,0x40,0x02,0x3E,0xFC,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"}",93*/
{0x00,0x00,0x60,0x00,0x80,0x00,0x80,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x20,0x00},/*"~",94*/
};
static const uint8_t Font1612[11][32] =
{
{0x00,0x00,0x3F,0xFC,0x3F,0xFC,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,
0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"0",0*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,
0x30,0x00,0x3F,0xFC,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"1",1*/
{0x00,0x00,0x39,0xFC,0x39,0xFC,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,
0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x3F,0x8C,0x3F,0x8C,0x00,0x00},/*"2",2*/
{0x00,0x00,0x38,0x1C,0x38,0x1C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,
0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"3",3*/
{0x00,0x00,0x3F,0x80,0x3F,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,
0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"4",4*/
{0x00,0x00,0x3F,0xBC,0x3F,0xBC,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,
0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0xFC,0x31,0xFC,0x00,0x00},/*"5",5*/
{0x00,0x00,0x3F,0x9C,0x3F,0x9C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,
0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0xFC,0x31,0xFC,0x00,0x00},/*"6",6*/
{0x00,0x00,0x38,0x00,0x38,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,
0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"7",7*/
{0x00,0x00,0x3F,0xFC,0x3F,0xFC,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,
0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"8",8*/
{0x00,0x00,0x3F,0x9C,0x3F,0x9C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,
0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"9",9*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x30,
0x18,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*":",10*/
};
static const uint8_t Font3216[11][64] =
{
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC, /*"0",0*/
0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,
0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,
0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*"1",1*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x01,0xFF,0xFC,0x3C,0x01,0xFF,0xFC, /*"2",2*/
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x3F,0xFF,0x80,0x0C,0x3F,0xFF,0x80,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x3C,0x38,0x00,0x00,0x3C, /*"3",3*/
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x80,0x00,0x3F,0xFF,0x80,0x00, /*"4",4*/
0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,
0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,
0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x80,0x3C,0x3F,0xFF,0x80,0x3C, /*"5",5*/
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x30,0x01,0xFF,0xFC,0x30,0x01,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC, /*"6",6*/
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x3C,0x01,0xFF,0xFC,0x3C,0x01,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x3C,0x00,0x00,0x00, /*"7",7*/
0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC, /*"8",8*/
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x80,0x3C,0x3F,0xFF,0x80,0x3C, /*"9",9*/
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*":",10*/
0x00,0x00,0x00,0x00,0x0F,0xF0,0x0F,0xF0,0x0F,0xF0,0x0F,0xF0,0x0C,0x00,0x00,0x30,
0x0C,0x00,0x00,0x30,0x0F,0xF0,0x0F,0xF0,0x0F,0xF0,0x0F,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
};
static const uint8_t Bmp4016[96] = //SUN
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xF1,0x81,0x8F,0xFC,0x3F,
0xF1,0x81,0x8F,0xFC,0x30,0x31,0x81,0x8C,0x0C,0x30,0x01,0x81,0x8C,0x0C,0x30,0x01,
0x81,0x8C,0x0C,0x3F,0xF1,0x81,0x8C,0x0C,0x3F,0xF1,0x81,0x8C,0x0C,0x00,0x31,0x81,
0x8C,0x0C,0x00,0x31,0x81,0x8C,0x0C,0x30,0x31,0x81,0x8C,0x0C,0x3F,0xF1,0xFF,0x8C,
0x0C,0x3F,0xF1,0xFF,0x8C,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
static const uint8_t Singal816[16] = //mobie singal
{
0xFE,0x02,0x92,0x0A,0x54,0x2A,0x38,0xAA,0x12,0xAA,0x12,0xAA,0x12,0xAA,0x12,0xAA
};
static const uint8_t Msg816[16] = //message
{
0x1F,0xF8,0x10,0x08,0x18,0x18,0x14,0x28,0x13,0xC8,0x10,0x08,0x10,0x08,0x1F,0xF8
};
static const uint8_t Bat816[16] = //batery
{
0x0F,0xFE,0x30,0x02,0x26,0xDA,0x26,0xDA,0x26,0xDA,0x26,0xDA,0x30,0x02,0x0F,0xFE
};
static const uint8_t Bluetooth88[8] = // bluetooth
{
0x18,0x54,0x32,0x1C,0x1C,0x32,0x54,0x18
};
static const uint8_t GPRS88[8] = //GPRS
{
0xC3,0x99,0x24,0x20,0x2C,0x24,0x99,0xC3
};
static const uint8_t Alarm88[8] = //alram
{
0xC3,0xBD,0x42,0x52,0x4E,0x42,0x3C,0xC3
};
#endif

View File

@ -0,0 +1,50 @@
#include <bcm2835.h>
#include <stdio.h>
#include <time.h>
#include "SSD1306.h"
char value[10]={'0','1','2','3','4','5','6','7','8','9'};
int main(int argc,char **argv)
{
time_t now;
struct tm *timenow;
if(!bcm2835_init())return 1;
printf("OLED Test Program !!!\n");
SSD1306_begin();
SSD1306_bitmap(0,0,waveshare,128,64);
SSD1306_display();
bcm2835_delay(2000);
SSD1306_clear();
while(1)
{
time(&now);
timenow = localtime(&now);
SSD1306_bitmap(0, 2, Singal816, 16, 8);
SSD1306_bitmap(24, 2,Bluetooth88, 8, 8);
SSD1306_bitmap(40, 2, Msg816, 16, 8);
SSD1306_bitmap(64, 2, GPRS88, 8, 8);
SSD1306_bitmap(90, 2, Alarm88, 8, 8);
SSD1306_bitmap(112, 2, Bat816, 16, 8);
SSD1306_string(0, 52, "MUSIC", 12, 0);
SSD1306_string(52, 52, "MENU", 12, 0);
SSD1306_string(98, 52, "PHONE", 12, 0);
SSD1306_char3216(0,16, value[timenow->tm_hour/10]);
SSD1306_char3216(16,16, value[timenow->tm_hour%10]);
SSD1306_char3216(32,16, ':');
SSD1306_char3216(48,16, value[timenow->tm_min/10]);
SSD1306_char3216(64,16, value[timenow->tm_min%10]);
SSD1306_char3216(80,16, ':');
SSD1306_char3216(96,16, value[timenow->tm_sec/10]);
SSD1306_char3216(112,16, value[timenow->tm_sec%10]);
SSD1306_display();
}
bcm2835_spi_end();
bcm2835_close();
return 0;
}

View File

@ -0,0 +1,172 @@
import spidev
import RPi.GPIO as GPIO
import time
# Constants
SSD1306_SETCONTRAST = 0x81
SSD1306_DISPLAYALLON_RESUME = 0xA4
SSD1306_DISPLAYALLON = 0xA5
SSD1306_NORMALDISPLAY = 0xA6
SSD1306_INVERTDISPLAY = 0xA7
SSD1306_DISPLAYOFF = 0xAE
SSD1306_DISPLAYON = 0xAF
SSD1306_SETDISPLAYOFFSET = 0xD3
SSD1306_SETCOMPINS = 0xDA
SSD1306_SETVCOMDETECT = 0xDB
SSD1306_SETDISPLAYCLOCKDIV = 0xD5
SSD1306_SETPRECHARGE = 0xD9
SSD1306_SETMULTIPLEX = 0xA8
SSD1306_SETLOWCOLUMN = 0x00
SSD1306_SETHIGHCOLUMN = 0x10
SSD1306_SETSTARTLINE = 0x40
SSD1306_MEMORYMODE = 0x20
SSD1306_COLUMNADDR = 0x21
SSD1306_PAGEADDR = 0x22
SSD1306_COMSCANINC = 0xC0
SSD1306_COMSCANDEC = 0xC8
SSD1306_SEGREMAP = 0xA0
SSD1306_CHARGEPUMP = 0x8D
SSD1306_EXTERNALVCC = 0x1
SSD1306_SWITCHCAPVCC = 0x2
# Scrolling constants
SSD1306_ACTIVATE_SCROLL = 0x2F
SSD1306_DEACTIVATE_SCROLL = 0x2E
SSD1306_SET_VERTICAL_SCROLL_AREA = 0xA3
SSD1306_RIGHT_HORIZONTAL_SCROLL = 0x26
SSD1306_LEFT_HORIZONTAL_SCROLL = 0x27
SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL = 0x29
SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL = 0x2A
class SSD1306(object):
"""class for SSD1306 128*64 0.96inch OLED displays."""
def __init__(self,rst,dc,spi):
self.width = 128
self.height = 64
self._pages = 8
self._buffer = [0]*(self.width*self._pages)
#Initialize DC RST pin
self._dc = dc
self._rst = rst
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(self._dc,GPIO.OUT)
GPIO.setup(self._rst,GPIO.OUT)
#Initialize SPI
self._spi = spi
def command(self,cmd):
"""Send command byte to display"""
GPIO.output(self._dc,GPIO.LOW)
self._spi.writebytes([cmd])
def data(self,val):
"""Send byte of data to display"""
GPIO.output(self._dc,GPIO.HIGHT)
self._spi.writebytes([val])
def begin(self,vccstate=SSD1306_SWITCHCAPVCC):
"""Initialize dispaly"""
self._vccstate = vccstate
self.reset()
self.command(SSD1306_DISPLAYOFF) # 0xAE
self.command(SSD1306_SETDISPLAYCLOCKDIV) # 0xD5
self.command(0x80) # the suggested ra tio 0x80
self.command(SSD1306_SETMULTIPLEX) # 0xA8
self.command(0x3F)
self.command(SSD1306_SETDISPLAYOFFSET) # 0xD3
self.command(0x0) # no offset
self.command(SSD1306_SETSTARTLINE | 0x0) # line #0
self.command(SSD1306_CHARGEPUMP) # 0x8D
if self._vccstate == SSD1306_EXTERNALVCC:
self.command(0x10)
else:
self.command(0x14)
self.command(SSD1306_MEMORYMODE) # 0x20
self.command(0x00) # 0x0 act like ks0108
self.command(SSD1306_SEGREMAP | 0x1)
self.command(SSD1306_COMSCANDEC)
self.command(SSD1306_SETCOMPINS) # 0xDA
self.command(0x12)
self.command(SSD1306_SETCONTRAST) # 0x81
if self._vccstate == SSD1306_EXTERNALVCC:
self.command(0x9F)
else:
self.command(0xCF)
self.command(SSD1306_SETPRECHARGE) # 0xd9
if self._vccstate == SSD1306_EXTERNALVCC:
self.command(0x22)
else:
self.command(0xF1)
self.command(SSD1306_SETVCOMDETECT) # 0xDB
self.command(0x40)
self.command(SSD1306_DISPLAYALLON_RESUME) # 0xA4
self.command(SSD1306_NORMALDISPLAY) # 0xA6
self.command(SSD1306_DISPLAYON)
def reset(self):
"""Reset the display"""
GPIO.output(self._rst,GPIO.HIGH)
time.sleep(0.001)
GPIO.output(self._rst,GPIO.LOW)
time.sleep(0.010)
GPIO.output(self._rst,GPIO.HIGH)
def display(self):
"""Write display buffer to physical display"""
self.command(SSD1306_COLUMNADDR)
self.command(0) #Cloumn start address
self.command(self.width-1) #Cloumn end address
self.command(SSD1306_PAGEADDR)
self.command(0) #Page start address
self.command(self._pages-1) #Page end address
#Write buffer data
GPIO.output(self._dc,GPIO.HIGH)
self._spi.writebytes(self._buffer)
def image(self, image):
"""Set buffer to value of Python Imaging Library image."""
if image.mode != '1':
raise ValueError('Image must be in mode 1.')
imwidth, imheight = image.size
if imwidth != self.width or imheight != self.height:
raise ValueError('Image must be same dimensions as display \
({0}x{1}).' .format(self.width, self.height))
pix = image.load()
# Iterate through the memory pages
index = 0
for page in range(self._pages):
# Iterate through all x axis columns.
for x in range(self.width):
# Set the bits for the column of pixels at the current position.
bits = 0
# Don't use range here as it's a bit slow
for bit in [0, 1, 2, 3, 4, 5, 6, 7]:
bits = bits << 1
bits |= 0 if pix[(x, page*8+7-bit)] == 0 else 1
# Update buffer byte and increment to next byte.
self._buffer[index] = bits
index += 1
def clear(self):
"""Clear contents of image buffer"""
self._buffer = [0]*(self.width*self._pages)
def set_contrast(self, contrast):
"""Sets the contrast of the display.
Contrast should be a value between 0 and 255."""
if contrast < 0 or contrast > 255:
raise ValueError('Contrast must be a value from 0 to 255).')
self.command(SSD1306_SETCONTRAST)
self.command(contrast)
def dim(self, dim):
"""Adjusts contrast to dim the display if dim is True,
otherwise sets the contrast to normal brightness if dim is False."""
# Assume dim display.
contrast = 0
# Adjust contrast based on VCC if not dimming.
if not dim:
if self._vccstate == SSD1306_EXTERNALVCC:
contrast = 0x9F
else:
contrast = 0xCF

View File

@ -0,0 +1,91 @@
# Copyright (c) 2015 WaveShare
# Author: My MX
import math
import time
import spidev as SPI
import SSD1306
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw
# Raspberry Pi pin configuration:
RST = 19
DC = 16
bus = 0
device = 0
# 128x32 display with hardware SPI:
disp = SSD1306.SSD1306(rst=RST,dc=DC,spi=SPI.SpiDev(bus,device))
# Initialize library.
disp.begin()
# Get display width and height.
width = disp.width
height = disp.height
# Clear display.
disp.clear()
disp.display()
# Create image buffer.
# Make sure to create image with mode '1' for 1-bit color.
image = Image.new('1', (width, height))
# Load default font.
font = ImageFont.load_default()
# Alternatively load a TTF font. Make sure the .ttf font file is in the same directory as this python script!
# Some nice fonts to try: http://www.dafont.com/bitmap.php
# font = ImageFont.truetype('Minecraftia.ttf', 8)
# Create drawing object.
draw = ImageDraw.Draw(image)
# Define text and get total width.
text = 'SSD1306 ORGANIC LED DISPLAY. THIS IS AN OLD SCHOOL DEMO SCROLLER!! GREETZ TO: LADYADA & THE ADAFRUIT CREW, TRIXTER, FUTURE CREW, AND FARBRAUSCH'
maxwidth, unused = draw.textsize(text, font=font)
# Set animation and sine wave parameters.
amplitude = height/4
offset = height/2 - 4
velocity = -2
startpos = width
# Animate text moving in sine wave.
print("Press Ctrl-C to quit.")
pos = startpos
while True:
# Clear image buffer by drawing a black filled box.
draw.rectangle((0,0,width,height), outline=0, fill=0)
# Enumerate characters and draw them offset vertically based on a sine wave.
x = pos
for i, c in enumerate(text):
# Stop drawing if off the right side of screen.
if x > width:
break
# Calculate width but skip drawing if off the left side of screen.
if x < -10:
char_width, char_height = draw.textsize(c, font=font)
x += char_width
continue
# Calculate offset from sine wave.
y = offset+math.floor(amplitude*math.sin(x/float(width)*2.0*math.pi))
# Draw text.
draw.text((x, y), c, font=font, fill=255)
# Increment x position based on chacacter width.
char_width, char_height = draw.textsize(c, font=font)
x += char_width
# Draw the image buffer.
disp.image(image)
disp.display()
# Move position for next frame.
pos += velocity
# Start over if text has scrolled completely off left side of screen.
if pos < -maxwidth:
pos = startpos
# Pause briefly before drawing next frame.
time.sleep(0.1)

View File

@ -0,0 +1,62 @@
import time
import spidev as SPI
import SSD1306
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
# Raspberry Pi pin configuration:
RST = 19
# Note the following are only used with SPI:
DC = 16
bus = 0
device = 0
# 128x64 display with hardware SPI:
disp = SSD1306.SSD1306(RST, DC, SPI.SpiDev(bus,device))
# Initialize library.
disp.begin()
# Clear display.
disp.clear()
disp.display()
# Create blank image for drawing.
# Make sure to create image with mode '1' for 1-bit color.
width = disp.width
height = disp.height
image = Image.new('1', (width, height))
# Get drawing object to draw on image.
draw = ImageDraw.Draw(image)
# Draw a black filled box to clear the image.
draw.rectangle((0,0,width,height), outline=0, fill=0)
# Draw some shapes.
# First define some constants to allow easy resizing of shapes.
padding = 1
top = padding
x = padding
# Load default font.
font = ImageFont.load_default()
# Alternatively load a TTF font.
# Some other nice fonts to try: http://www.dafont.com/bitmap.php
#font = ImageFont.truetype('Minecraftia.ttf', 8)
# Write two lines of text.
draw.text((x, top), 'This is first line', font=font, fill=255)
draw.text((x, top+10), 'This is second line', font=font, fill=255)
draw.text((x, top+20), 'This is third line', font=font, fill=255)
draw.text((x, top+30), 'This is fourth line', font=font, fill=255)
draw.text((x, top+40), 'This is fifth line', font=font, fill=255)
draw.text((x, top+50), 'This is last line', font=font, fill=255)
# Display image.
disp.image(image)
disp.display()

Binary file not shown.

View File

@ -0,0 +1,36 @@
# Copyright (c) 2015 WaveShare
# Author: My MX
import time
import spidev as SPI
import SSD1306
from PIL import Image
# Raspberry Pi pin configuration:
RST = 19
DC = 16
bus = 0
device = 0
# 128x32 display with hardware I2C:
disp = SSD1306.SSD1306(rst=RST,dc=DC,spi=SPI.SpiDev(bus,device))
# Initialize library.
disp.begin()
# Clear display.
disp.clear()
disp.display()
# Load image based on OLED display height. Note that image is converted to 1 bit color.
image = Image.open('happycat.ppm').convert('1')
# Alternatively load a different format image, resize it, and convert to 1 bit color.
#image = Image.open('happycat.png').resize((disp.width, disp.height), Image.ANTIALIAS).convert('1')
# Display image.
disp.image(image)
disp.display()

View File

@ -0,0 +1,66 @@
import spidev as SPI
import SSD1306
import time
from PIL import Image,ImageDraw,ImageFont
# Raspberry Pi pin configuration:
RST = 19
DC = 16
bus = 0
device = 0
# 128x64 display with hardware SPI:
disp = SSD1306.SSD1306(RST, DC, SPI.SpiDev(bus, device))
# Initialize library.
disp.begin()
# Clear display.
disp.clear()
disp.display()
# Create blank image for drawing.
# Make sure to create image with mode '1' for 1-bit color.
width = disp.width
height = disp.height
image = Image.new('1', (width, height))
# Get drawing object to draw on image.
draw = ImageDraw.Draw(image)
# Draw a black filled box to clear the image.
draw.rectangle((0,0,width,height), outline=0, fill=0)
# Draw some shapes.
# First define some constants to allow easy resizing of shapes.
padding = 2
shape_width = 20
top = padding
bottom = height-padding
# Move left to right keeping track of the current x position for drawing shapes.
x = padding
# Draw an ellipse.
draw.ellipse((x, top , x+shape_width, bottom), outline=255, fill=0)
x += shape_width+padding
# Draw a rectangle.
draw.rectangle((x, top, x+shape_width, bottom), outline=255, fill=0)
x += shape_width+padding
# Draw a triangle.
draw.polygon([(x, bottom), (x+shape_width/2, top), (x+shape_width, bottom)], outline=255, fill=0)
x += shape_width+padding
# Draw an X.
draw.line((x, bottom, x+shape_width, top), fill=255)
draw.line((x, top, x+shape_width, bottom), fill=255)
x += shape_width+padding
# Load default font.
font = ImageFont.load_default()
# Write two lines of text.
draw.text((x, top), 'Hello', font=font, fill=255)
draw.text((x, top+20), 'World!', font=font, fill=255)
# Display image.
disp.image(image)
disp.display()

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,36 @@
# Copyright (c) 2015 WaveShare
# Author: My MX
import time
import spidev as SPI
import SSD1306
#import Image
from PIL import Image
# Raspberry Pi pin configuration:
RST = 19
DC = 16
bus = 0
device = 0
# 128x32 display with hardware I2C:
disp = SSD1306.SSD1306(rst=RST,dc=DC,spi=SPI.SpiDev(bus,device))
# Initialize library.
disp.begin()
# Clear display.
disp.clear()
disp.display()
# Load image based on OLED display height. Note that image is converted to 1 bit color.
image = Image.open('waveshare.bmp').convert('1')
# Alternatively load a different format image, resize it, and convert to 1 bit color.
#image = Image.open('happycat.png').resize((disp.width, disp.height), Image.ANTIALIAS).convert('1')
# Display image.
disp.image(image)
disp.display()

View File

@ -0,0 +1,8 @@
oled:oled.o SSD1306.o
gcc -Wall -o oled oled.o SSD1306.o -lwiringPi
SSD1306.o:SSD1306.c SSD1306.h
gcc -Wall -c SSD1306.c -lwiringPi
oled.o:oled.c SSD1306.h
gcc -Wall -c oled.c -lwiringPi
clean:
rm SSD1306.o oled.o oled

View File

@ -0,0 +1,192 @@
#include <wiringPi.h>
#include <wiringPiSPI.h>
#include <stdio.h>
#include "SSD1306.h"
#define channel 0
#define vccstate SSD1306_SWITCHCAPVCC
#define width 128
#define height 64
#define pages 8
#define RST 24
#define DC 27
unsigned char buffer[1024];
void command(unsigned char cmd){
digitalWrite(DC,LOW);
wiringPiSPIDataRW(channel,&cmd,1);
}
void SSD1306_begin()
{
pinMode(RST,OUTPUT);
pinMode(DC,OUTPUT);
wiringPiSPISetup(channel,2000000); //2M
digitalWrite(RST,HIGH);
delay(10);
digitalWrite(RST,LOW);
delay(10);
digitalWrite(RST,HIGH);
command(SSD1306_DISPLAYOFF);
command(SSD1306_SETDISPLAYCLOCKDIV);
command(0x80); // the suggested ratio 0x80
command(SSD1306_SETMULTIPLEX);
command(0x3F);
command(SSD1306_SETDISPLAYOFFSET);
command(0x0); // no offset
command(SSD1306_SETSTARTLINE | 0x0); // line #0
command(SSD1306_CHARGEPUMP);
command((vccstate == SSD1306_EXTERNALVCC) ? 0x10 : 0x14);
command(SSD1306_MEMORYMODE);
command(0x00); // 0x0 act like ks0108
command(SSD1306_SEGREMAP | 0x1);
command(SSD1306_COMSCANDEC);
command(SSD1306_SETCOMPINS);
command(0x12); // TODO - calculate based on _rawHieght ?
command(SSD1306_SETCONTRAST);
command((vccstate == SSD1306_EXTERNALVCC) ? 0x9F : 0xCF);
command(SSD1306_SETPRECHARGE);
command((vccstate == SSD1306_EXTERNALVCC) ? 0x22 : 0xF1);
command(SSD1306_SETVCOMDETECT);
command(0x40);
command(SSD1306_DISPLAYALLON_RESUME);
command(SSD1306_NORMALDISPLAY);
command(SSD1306_DISPLAYON);
}
void SSD1306_clear()
{
int i;
for(i = 0;i<sizeof(buffer);i++)
{
buffer[i] = 0;
}
}
void SSD1306_pixel(int x,int y,char color)
{
if(x > width || y > height)return ;
if(color)
buffer[x+(y/8)*width] |= 1<<(y%8);
else
buffer[x+(y/8)*width] &= ~(1<<(y%8));
}
void SSD1306_char1616(unsigned char x,unsigned char y,unsigned char chChar)
{
unsigned char i, j;
unsigned char chTemp = 0, y0 = y, chMode = 0;
for (i = 0; i < 32; i ++) {
chTemp = Font1612[chChar - 0x30][i];
for (j = 0; j < 8; j ++) {
chMode = chTemp & 0x80? 1 : 0;
SSD1306_pixel(x, y, chMode);
chTemp <<= 1;
y ++;
if ((y - y0) == 16) {
y = y0;
x ++;
break;
}
}
}
}
void SSD1306_char3216(unsigned char x,unsigned char y,unsigned char chChar)
{
unsigned char i, j;
unsigned char chTemp = 0, y0 = y, chMode = 0;
for (i = 0; i < 64; i ++) {
chTemp = Font3216[chChar - 0x30][i];
for (j = 0; j < 8; j ++) {
chMode = chTemp & 0x80? 1 : 0;
SSD1306_pixel(x, y, chMode);
chTemp <<= 1;
y ++;
if ((y - y0) == 32) {
y = y0;
x ++;
break;
}
}
}
}
void SSD1306_char(unsigned char x,unsigned char y,char acsii,char size,char mode)
{
unsigned char i,j,y0=y;
char temp;
unsigned char ch = acsii - ' ';
for(i = 0;i<size;i++)
{
if(size == 12)
{
if(mode)temp=Font1206[ch][i];
else temp = ~Font1206[ch][i];
}
else
{
if(mode)temp=Font1608[ch][i];
else temp = ~Font1608[ch][i];
}
for(j =0;j<8;j++)
{
if(temp & 0x80) SSD1306_pixel(x,y,1);
else SSD1306_pixel(x,y,0);
temp <<=1;
y++;
if((y-y0)==size)
{
y = y0;
x ++;
break;
}
}
}
}
void SSD1306_string(unsigned char x,unsigned char y, const char *pString,
unsigned char Size,unsigned char Mode)
{
while (*pString != '\0') {
if (x > (width - Size / 2)) {
x = 0;
y += Size;
if (y > (height - Size)) {
y = x = 0;
}
}
SSD1306_char(x, y, *pString, Size, Mode);
x += Size / 2;
pString ++;
}
}
void SSD1306_bitmap(unsigned char x,unsigned char y,const unsigned char *pBmp,
char chWidth,char chHeight)
{
unsigned char i,j,byteWidth = (chWidth + 7)/8;
for(j = 0;j < chHeight;j++){
for(i = 0;i <chWidth;i ++){
if(*(pBmp +j*byteWidth+i/8) & (128 >> (i & 7))){
SSD1306_pixel(x+i,y+j,1);
}
}
}
}
void SSD1306_display()
{
command(SSD1306_COLUMNADDR);
command(0); //cloumn start address
command(width -1); //cloumn end address
command(SSD1306_PAGEADDR);
command(0); //page atart address
command(pages -1); //page end address
digitalWrite(DC,HIGH);
wiringPiSPIDataRW(channel,buffer,sizeof(buffer));
}

View File

@ -0,0 +1,437 @@
#ifndef _SSD1306_H_
#define _SSD1306_H_
#define SSD1306_SETCONTRAST 0x81
#define SSD1306_DISPLAYALLON_RESUME 0xA4
#define SSD1306_DISPLAYALLON 0xA5
#define SSD1306_NORMALDISPLAY 0xA6
#define SSD1306_INVERTDISPLAY 0xA7
#define SSD1306_DISPLAYOFF 0xAE
#define SSD1306_DISPLAYON 0xAF
#define SSD1306_SETDISPLAYOFFSET 0xD3
#define SSD1306_SETCOMPINS 0xDA
#define SSD1306_SETVCOMDETECT 0xDB
#define SSD1306_SETDISPLAYCLOCKDIV 0xD5
#define SSD1306_SETPRECHARGE 0xD9
#define SSD1306_SETMULTIPLEX 0xA8
#define SSD1306_SETLOWCOLUMN 0x00
#define SSD1306_SETHIGHCOLUMN 0x10
#define SSD1306_SETSTARTLINE 0x40
#define SSD1306_MEMORYMODE 0x20
#define SSD1306_COLUMNADDR 0x21
#define SSD1306_PAGEADDR 0x22
#define SSD1306_COMSCANINC 0xC0
#define SSD1306_COMSCANDEC 0xC8
#define SSD1306_SEGREMAP 0xA0
#define SSD1306_CHARGEPUMP 0x8D
#define SSD1306_EXTERNALVCC 0x01
#define SSD1306_SWITCHCAPVCC 0x02
//Scrolling constants
#define SSD1306_ACTIVATE_SCROLL 0x2F
#define SSD1306_DEACTIVATE_SCROLL 0x2E
#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3
#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26
#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27
#define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29
#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A
void SSD1306_begin();
void SSD1306_display();
void SSD1306_clear();
void SSD1306_pixel(int x,int y,char color);
void SSD1306_bitmap(unsigned char x,unsigned char y,const unsigned char *pBmp,
char chWidth,char chHeight);
void SSD1306_string(unsigned char x,unsigned char y, const char *pString,
unsigned char Size,unsigned char Mode);
void SSD1306_char1616(unsigned char x,unsigned char y,unsigned char chChar);
void SSD1306_char3216(unsigned char x,unsigned char y,unsigned char chChar);
static const unsigned char waveshare[1024]=
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x11,0x11,0x00,0x9C,0x64,0x42,0x1C,0x78,0x7A,0x78,0xEF,0xB8,0x30,0x89,0x8C,0x70,
0x19,0x91,0x88,0x9C,0xF4,0x63,0x1E,0x78,0x7A,0x79,0xEF,0x3C,0x78,0x89,0x9E,0xF0,
0x09,0x91,0x88,0xB1,0x84,0x63,0x12,0x40,0x42,0x43,0x02,0x24,0xCC,0xC9,0x30,0x80,
0x09,0x91,0x88,0xB1,0x84,0x67,0x12,0x40,0x42,0x42,0x02,0x24,0x84,0xC9,0x20,0x80,
0x09,0x92,0x89,0xB0,0x84,0x65,0x12,0x40,0x42,0x42,0x02,0x24,0x84,0xC9,0x20,0xC0,
0x0A,0xB2,0x4D,0x1C,0xC7,0xE5,0x96,0x78,0x7A,0x72,0x02,0x2C,0x84,0xA9,0x20,0x60,
0x0A,0xA2,0x45,0x14,0x67,0xE4,0x9C,0x70,0x72,0x52,0x02,0x38,0x84,0xA9,0x20,0x30,
0x0A,0x63,0xC5,0x30,0x34,0x67,0x94,0x40,0x42,0x42,0x02,0x28,0x84,0xB9,0x20,0x10,
0x06,0x67,0xC7,0x30,0x14,0x6F,0x92,0x40,0x42,0x42,0x02,0x24,0x84,0x99,0x20,0x10,
0x06,0x64,0x66,0x30,0x14,0x68,0x92,0x40,0x42,0x43,0x02,0x24,0x8C,0x99,0x20,0x10,
0x06,0x64,0x22,0x3D,0xB4,0x68,0xD3,0x78,0x7A,0x79,0xE2,0x26,0x78,0x89,0xBE,0xF0,
0x04,0x44,0x22,0x1C,0xE4,0x48,0x51,0x78,0x7A,0x79,0xE2,0x22,0x70,0x89,0x9E,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3F,0xFF,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3F,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3F,0xFF,0xFF,0x80,0x00,0x08,0x30,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,
0x3F,0xFF,0xF7,0xC0,0x06,0xDB,0x30,0x3F,0xFF,0xFC,0x00,0x70,0x00,0x7F,0xFF,0xF0,
0x3F,0xFF,0xE7,0xE0,0x0E,0xDB,0x30,0x3F,0xFF,0xFC,0x7F,0xFF,0xF8,0x7F,0xFF,0xF0,
0x3F,0xFF,0xC7,0xF0,0x0C,0xDB,0x7E,0x00,0x18,0x00,0x7F,0xFF,0xF8,0x7F,0xFF,0xF0,
0x3F,0xFF,0x87,0xF0,0x1C,0xDB,0xFE,0x00,0x18,0x00,0x7F,0xFF,0xF8,0x00,0x00,0xF0,
0x3F,0xFF,0x07,0xF8,0x1C,0xDB,0xF0,0x3F,0xFF,0xFC,0x60,0x70,0x38,0x00,0x01,0xE0,
0x3F,0xFF,0x87,0xFC,0x18,0xDB,0xC0,0x3F,0xFF,0xF8,0x60,0x70,0x38,0x00,0x01,0xC0,
0x20,0xC3,0x86,0x3C,0x06,0xFF,0x00,0x30,0x18,0x18,0x60,0x70,0x38,0x00,0x03,0xC0,
0x30,0xC3,0x0C,0x3C,0x06,0xFF,0x0C,0x30,0x18,0x18,0x60,0x70,0x38,0x00,0x03,0x80,
0x30,0x43,0x0C,0x1E,0x0E,0xFF,0x6C,0x33,0x18,0xD8,0x60,0x70,0x38,0x07,0xFF,0x00,
0x30,0x00,0x1C,0x1E,0x0E,0x00,0x6C,0x33,0x9B,0xD8,0x70,0x70,0x38,0x07,0xFF,0x00,
0x38,0x00,0x08,0x0E,0x1C,0xFE,0x7C,0x30,0x18,0x18,0x7F,0xFF,0xF8,0x07,0xFE,0x00,
0x38,0x00,0x08,0x0E,0x1C,0xFE,0x3C,0x30,0x19,0x18,0x7F,0xFF,0xF8,0x07,0xFE,0x00,
0x38,0x00,0x00,0x06,0x1C,0xFE,0x38,0x31,0x9B,0x98,0x60,0x70,0x38,0x00,0x0E,0x00,
0x3C,0x10,0x00,0x86,0x0C,0x00,0x38,0x33,0x99,0xD8,0x60,0x70,0x38,0x00,0x0E,0x00,
0x3C,0x10,0x00,0x82,0x0C,0x00,0x38,0x00,0x00,0x00,0x60,0x70,0x38,0x00,0x0E,0x00,
0x3C,0x18,0x41,0x86,0x0C,0x7E,0x38,0x00,0x00,0x00,0x60,0x70,0x38,0xFF,0xFF,0xF0,
0x1E,0x38,0x41,0x86,0x0C,0x7E,0x18,0x3F,0xFF,0xF8,0x60,0x70,0x38,0xFF,0xFF,0xF0,
0x1E,0x38,0xE3,0x8E,0x0C,0x7E,0x18,0x3F,0xFF,0xF8,0x60,0x70,0x38,0xFF,0xFF,0xF0,
0x1E,0x7C,0xE2,0x0E,0x0C,0x66,0x38,0x00,0x00,0x18,0x7F,0xFF,0xF8,0x00,0x0E,0x00,
0x1F,0xFF,0xFE,0x1E,0x0C,0x66,0x38,0x00,0x00,0x18,0x7F,0xFF,0xF0,0x00,0x0E,0x00,
0x0F,0xFF,0xFE,0x0E,0x0C,0x66,0x38,0x1F,0xFF,0xF8,0x7F,0xFF,0xF0,0x00,0x0E,0x00,
0x0F,0xFF,0xFE,0x1E,0x0C,0x66,0x3C,0x1F,0xFF,0xF8,0x00,0x70,0x00,0x00,0x0E,0x00,
0x07,0xFF,0xFE,0x3E,0x0C,0x66,0x3C,0x10,0x00,0x38,0x00,0x70,0x00,0x00,0x0E,0x00,
0x03,0xFF,0xFE,0x7E,0x0C,0x66,0x7C,0x00,0x00,0x18,0x00,0x70,0x00,0x00,0x1E,0x00,
0x01,0xFF,0xFE,0xFE,0x0C,0xE7,0xEE,0x00,0x00,0x18,0x00,0x7F,0xF8,0x3F,0xFE,0x00,
0x00,0xFF,0xFF,0xFE,0x0C,0xE7,0xEE,0x3F,0xFF,0xF8,0x00,0x3F,0xF8,0x3F,0xFE,0x00,
0x00,0x7F,0xFF,0xFE,0x0C,0xC7,0xC6,0x3F,0xFF,0xF8,0x00,0x3F,0xF8,0x3F,0xFC,0x00,
0x00,0x1F,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
static const unsigned char Font1206[95][12] = {
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/
{0x00,0x00,0x00,0x00,0x3F,0x40,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",1*/
{0x00,0x00,0x30,0x00,0x40,0x00,0x30,0x00,0x40,0x00,0x00,0x00},/*""",2*/
{0x09,0x00,0x0B,0xC0,0x3D,0x00,0x0B,0xC0,0x3D,0x00,0x09,0x00},/*"#",3*/
{0x18,0xC0,0x24,0x40,0x7F,0xE0,0x22,0x40,0x31,0x80,0x00,0x00},/*"$",4*/
{0x18,0x00,0x24,0xC0,0x1B,0x00,0x0D,0x80,0x32,0x40,0x01,0x80},/*"%",5*/
{0x03,0x80,0x1C,0x40,0x27,0x40,0x1C,0x80,0x07,0x40,0x00,0x40},/*"&",6*/
{0x10,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x80,0x20,0x40,0x40,0x20},/*"(",8*/
{0x00,0x00,0x40,0x20,0x20,0x40,0x1F,0x80,0x00,0x00,0x00,0x00},/*")",9*/
{0x09,0x00,0x06,0x00,0x1F,0x80,0x06,0x00,0x09,0x00,0x00,0x00},/*"*",10*/
{0x04,0x00,0x04,0x00,0x3F,0x80,0x04,0x00,0x04,0x00,0x00,0x00},/*"+",11*/
{0x00,0x10,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*",",12*/
{0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00},/*"-",13*/
{0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*".",14*/
{0x00,0x20,0x01,0xC0,0x06,0x00,0x38,0x00,0x40,0x00,0x00,0x00},/*"/",15*/
{0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"0",16*/
{0x00,0x00,0x10,0x40,0x3F,0xC0,0x00,0x40,0x00,0x00,0x00,0x00},/*"1",17*/
{0x18,0xC0,0x21,0x40,0x22,0x40,0x24,0x40,0x18,0x40,0x00,0x00},/*"2",18*/
{0x10,0x80,0x20,0x40,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"3",19*/
{0x02,0x00,0x0D,0x00,0x11,0x00,0x3F,0xC0,0x01,0x40,0x00,0x00},/*"4",20*/
{0x3C,0x80,0x24,0x40,0x24,0x40,0x24,0x40,0x23,0x80,0x00,0x00},/*"5",21*/
{0x1F,0x80,0x24,0x40,0x24,0x40,0x34,0x40,0x03,0x80,0x00,0x00},/*"6",22*/
{0x30,0x00,0x20,0x00,0x27,0xC0,0x38,0x00,0x20,0x00,0x00,0x00},/*"7",23*/
{0x1B,0x80,0x24,0x40,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"8",24*/
{0x1C,0x00,0x22,0xC0,0x22,0x40,0x22,0x40,0x1F,0x80,0x00,0x00},/*"9",25*/
{0x00,0x00,0x00,0x00,0x08,0x40,0x00,0x00,0x00,0x00,0x00,0x00},/*":",26*/
{0x00,0x00,0x00,0x00,0x04,0x60,0x00,0x00,0x00,0x00,0x00,0x00},/*";",27*/
{0x00,0x00,0x04,0x00,0x0A,0x00,0x11,0x00,0x20,0x80,0x40,0x40},/*"<",28*/
{0x09,0x00,0x09,0x00,0x09,0x00,0x09,0x00,0x09,0x00,0x00,0x00},/*"=",29*/
{0x00,0x00,0x40,0x40,0x20,0x80,0x11,0x00,0x0A,0x00,0x04,0x00},/*">",30*/
{0x18,0x00,0x20,0x00,0x23,0x40,0x24,0x00,0x18,0x00,0x00,0x00},/*"?",31*/
{0x1F,0x80,0x20,0x40,0x27,0x40,0x29,0x40,0x1F,0x40,0x00,0x00},/*"@",32*/
{0x00,0x40,0x07,0xC0,0x39,0x00,0x0F,0x00,0x01,0xC0,0x00,0x40},/*"A",33*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x24,0x40,0x1B,0x80,0x00,0x00},/*"B",34*/
{0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x30,0x80,0x00,0x00},/*"C",35*/
{0x20,0x40,0x3F,0xC0,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"D",36*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x2E,0x40,0x30,0xC0,0x00,0x00},/*"E",37*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x2E,0x00,0x30,0x00,0x00,0x00},/*"F",38*/
{0x0F,0x00,0x10,0x80,0x20,0x40,0x22,0x40,0x33,0x80,0x02,0x00},/*"G",39*/
{0x20,0x40,0x3F,0xC0,0x04,0x00,0x04,0x00,0x3F,0xC0,0x20,0x40},/*"H",40*/
{0x20,0x40,0x20,0x40,0x3F,0xC0,0x20,0x40,0x20,0x40,0x00,0x00},/*"I",41*/
{0x00,0x60,0x20,0x20,0x20,0x20,0x3F,0xC0,0x20,0x00,0x20,0x00},/*"J",42*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x0B,0x00,0x30,0xC0,0x20,0x40},/*"K",43*/
{0x20,0x40,0x3F,0xC0,0x20,0x40,0x00,0x40,0x00,0x40,0x00,0xC0},/*"L",44*/
{0x3F,0xC0,0x3C,0x00,0x03,0xC0,0x3C,0x00,0x3F,0xC0,0x00,0x00},/*"M",45*/
{0x20,0x40,0x3F,0xC0,0x0C,0x40,0x23,0x00,0x3F,0xC0,0x20,0x00},/*"N",46*/
{0x1F,0x80,0x20,0x40,0x20,0x40,0x20,0x40,0x1F,0x80,0x00,0x00},/*"O",47*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x24,0x00,0x18,0x00,0x00,0x00},/*"P",48*/
{0x1F,0x80,0x21,0x40,0x21,0x40,0x20,0xE0,0x1F,0xA0,0x00,0x00},/*"Q",49*/
{0x20,0x40,0x3F,0xC0,0x24,0x40,0x26,0x00,0x19,0xC0,0x00,0x40},/*"R",50*/
{0x18,0xC0,0x24,0x40,0x24,0x40,0x22,0x40,0x31,0x80,0x00,0x00},/*"S",51*/
{0x30,0x00,0x20,0x40,0x3F,0xC0,0x20,0x40,0x30,0x00,0x00,0x00},/*"T",52*/
{0x20,0x00,0x3F,0x80,0x00,0x40,0x00,0x40,0x3F,0x80,0x20,0x00},/*"U",53*/
{0x20,0x00,0x3E,0x00,0x01,0xC0,0x07,0x00,0x38,0x00,0x20,0x00},/*"V",54*/
{0x38,0x00,0x07,0xC0,0x3C,0x00,0x07,0xC0,0x38,0x00,0x00,0x00},/*"W",55*/
{0x20,0x40,0x39,0xC0,0x06,0x00,0x39,0xC0,0x20,0x40,0x00,0x00},/*"X",56*/
{0x20,0x00,0x38,0x40,0x07,0xC0,0x38,0x40,0x20,0x00,0x00,0x00},/*"Y",57*/
{0x30,0x40,0x21,0xC0,0x26,0x40,0x38,0x40,0x20,0xC0,0x00,0x00},/*"Z",58*/
{0x00,0x00,0x00,0x00,0x7F,0xE0,0x40,0x20,0x40,0x20,0x00,0x00},/*"[",59*/
{0x00,0x00,0x70,0x00,0x0C,0x00,0x03,0x80,0x00,0x40,0x00,0x00},/*"\",60*/
{0x00,0x00,0x40,0x20,0x40,0x20,0x7F,0xE0,0x00,0x00,0x00,0x00},/*"]",61*/
{0x00,0x00,0x20,0x00,0x40,0x00,0x20,0x00,0x00,0x00,0x00,0x00},/*"^",62*/
{0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10},/*"_",63*/
{0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/
{0x00,0x00,0x02,0x80,0x05,0x40,0x05,0x40,0x03,0xC0,0x00,0x40},/*"a",65*/
{0x20,0x00,0x3F,0xC0,0x04,0x40,0x04,0x40,0x03,0x80,0x00,0x00},/*"b",66*/
{0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x40,0x06,0x40,0x00,0x00},/*"c",67*/
{0x00,0x00,0x03,0x80,0x04,0x40,0x24,0x40,0x3F,0xC0,0x00,0x40},/*"d",68*/
{0x00,0x00,0x03,0x80,0x05,0x40,0x05,0x40,0x03,0x40,0x00,0x00},/*"e",69*/
{0x00,0x00,0x04,0x40,0x1F,0xC0,0x24,0x40,0x24,0x40,0x20,0x00},/*"f",70*/
{0x00,0x00,0x02,0xE0,0x05,0x50,0x05,0x50,0x06,0x50,0x04,0x20},/*"g",71*/
{0x20,0x40,0x3F,0xC0,0x04,0x40,0x04,0x00,0x03,0xC0,0x00,0x40},/*"h",72*/
{0x00,0x00,0x04,0x40,0x27,0xC0,0x00,0x40,0x00,0x00,0x00,0x00},/*"i",73*/
{0x00,0x10,0x00,0x10,0x04,0x10,0x27,0xE0,0x00,0x00,0x00,0x00},/*"j",74*/
{0x20,0x40,0x3F,0xC0,0x01,0x40,0x07,0x00,0x04,0xC0,0x04,0x40},/*"k",75*/
{0x20,0x40,0x20,0x40,0x3F,0xC0,0x00,0x40,0x00,0x40,0x00,0x00},/*"l",76*/
{0x07,0xC0,0x04,0x00,0x07,0xC0,0x04,0x00,0x03,0xC0,0x00,0x00},/*"m",77*/
{0x04,0x40,0x07,0xC0,0x04,0x40,0x04,0x00,0x03,0xC0,0x00,0x40},/*"n",78*/
{0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x40,0x03,0x80,0x00,0x00},/*"o",79*/
{0x04,0x10,0x07,0xF0,0x04,0x50,0x04,0x40,0x03,0x80,0x00,0x00},/*"p",80*/
{0x00,0x00,0x03,0x80,0x04,0x40,0x04,0x50,0x07,0xF0,0x00,0x10},/*"q",81*/
{0x04,0x40,0x07,0xC0,0x02,0x40,0x04,0x00,0x04,0x00,0x00,0x00},/*"r",82*/
{0x00,0x00,0x06,0x40,0x05,0x40,0x05,0x40,0x04,0xC0,0x00,0x00},/*"s",83*/
{0x00,0x00,0x04,0x00,0x1F,0x80,0x04,0x40,0x00,0x40,0x00,0x00},/*"t",84*/
{0x04,0x00,0x07,0x80,0x00,0x40,0x04,0x40,0x07,0xC0,0x00,0x40},/*"u",85*/
{0x04,0x00,0x07,0x00,0x04,0xC0,0x01,0x80,0x06,0x00,0x04,0x00},/*"v",86*/
{0x06,0x00,0x01,0xC0,0x07,0x00,0x01,0xC0,0x06,0x00,0x00,0x00},/*"w",87*/
{0x04,0x40,0x06,0xC0,0x01,0x00,0x06,0xC0,0x04,0x40,0x00,0x00},/*"x",88*/
{0x04,0x10,0x07,0x10,0x04,0xE0,0x01,0x80,0x06,0x00,0x04,0x00},/*"y",89*/
{0x00,0x00,0x04,0x40,0x05,0xC0,0x06,0x40,0x04,0x40,0x00,0x00},/*"z",90*/
{0x00,0x00,0x00,0x00,0x04,0x00,0x7B,0xE0,0x40,0x20,0x00,0x00},/*"{",91*/
{0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xF0,0x00,0x00,0x00,0x00},/*"|",92*/
{0x00,0x00,0x40,0x20,0x7B,0xE0,0x04,0x00,0x00,0x00,0x00,0x00},/*"}",93*/
{0x40,0x00,0x80,0x00,0x40,0x00,0x20,0x00,0x20,0x00,0x40,0x00},/*"~",94*/
};
static const unsigned char Font1608[95][16] = {
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*" ",0*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xCC,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00},/*"!",1*/
{0x00,0x00,0x08,0x00,0x30,0x00,0x60,0x00,0x08,0x00,0x30,0x00,0x60,0x00,0x00,0x00},/*""",2*/
{0x02,0x20,0x03,0xFC,0x1E,0x20,0x02,0x20,0x03,0xFC,0x1E,0x20,0x02,0x20,0x00,0x00},/*"#",3*/
{0x00,0x00,0x0E,0x18,0x11,0x04,0x3F,0xFF,0x10,0x84,0x0C,0x78,0x00,0x00,0x00,0x00},/*"$",4*/
{0x0F,0x00,0x10,0x84,0x0F,0x38,0x00,0xC0,0x07,0x78,0x18,0x84,0x00,0x78,0x00,0x00},/*"%",5*/
{0x00,0x78,0x0F,0x84,0x10,0xC4,0x11,0x24,0x0E,0x98,0x00,0xE4,0x00,0x84,0x00,0x08},/*"&",6*/
{0x08,0x00,0x68,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"'",7*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xE0,0x18,0x18,0x20,0x04,0x40,0x02,0x00,0x00},/*"(",8*/
{0x00,0x00,0x40,0x02,0x20,0x04,0x18,0x18,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00},/*")",9*/
{0x02,0x40,0x02,0x40,0x01,0x80,0x0F,0xF0,0x01,0x80,0x02,0x40,0x02,0x40,0x00,0x00},/*"*",10*/
{0x00,0x80,0x00,0x80,0x00,0x80,0x0F,0xF8,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x00},/*"+",11*/
{0x00,0x01,0x00,0x0D,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*",",12*/
{0x00,0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80},/*"-",13*/
{0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*".",14*/
{0x00,0x00,0x00,0x06,0x00,0x18,0x00,0x60,0x01,0x80,0x06,0x00,0x18,0x00,0x20,0x00},/*"/",15*/
{0x00,0x00,0x07,0xF0,0x08,0x08,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"0",16*/
{0x00,0x00,0x08,0x04,0x08,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"1",17*/
{0x00,0x00,0x0E,0x0C,0x10,0x14,0x10,0x24,0x10,0x44,0x11,0x84,0x0E,0x0C,0x00,0x00},/*"2",18*/
{0x00,0x00,0x0C,0x18,0x10,0x04,0x11,0x04,0x11,0x04,0x12,0x88,0x0C,0x70,0x00,0x00},/*"3",19*/
{0x00,0x00,0x00,0xE0,0x03,0x20,0x04,0x24,0x08,0x24,0x1F,0xFC,0x00,0x24,0x00,0x00},/*"4",20*/
{0x00,0x00,0x1F,0x98,0x10,0x84,0x11,0x04,0x11,0x04,0x10,0x88,0x10,0x70,0x00,0x00},/*"5",21*/
{0x00,0x00,0x07,0xF0,0x08,0x88,0x11,0x04,0x11,0x04,0x18,0x88,0x00,0x70,0x00,0x00},/*"6",22*/
{0x00,0x00,0x1C,0x00,0x10,0x00,0x10,0xFC,0x13,0x00,0x1C,0x00,0x10,0x00,0x00,0x00},/*"7",23*/
{0x00,0x00,0x0E,0x38,0x11,0x44,0x10,0x84,0x10,0x84,0x11,0x44,0x0E,0x38,0x00,0x00},/*"8",24*/
{0x00,0x00,0x07,0x00,0x08,0x8C,0x10,0x44,0x10,0x44,0x08,0x88,0x07,0xF0,0x00,0x00},/*"9",25*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0C,0x03,0x0C,0x00,0x00,0x00,0x00,0x00,0x00},/*":",26*/
{0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*";",27*/
{0x00,0x00,0x00,0x80,0x01,0x40,0x02,0x20,0x04,0x10,0x08,0x08,0x10,0x04,0x00,0x00},/*"<",28*/
{0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x00,0x00},/*"=",29*/
{0x00,0x00,0x10,0x04,0x08,0x08,0x04,0x10,0x02,0x20,0x01,0x40,0x00,0x80,0x00,0x00},/*">",30*/
{0x00,0x00,0x0E,0x00,0x12,0x00,0x10,0x0C,0x10,0x6C,0x10,0x80,0x0F,0x00,0x00,0x00},/*"?",31*/
{0x03,0xE0,0x0C,0x18,0x13,0xE4,0x14,0x24,0x17,0xC4,0x08,0x28,0x07,0xD0,0x00,0x00},/*"@",32*/
{0x00,0x04,0x00,0x3C,0x03,0xC4,0x1C,0x40,0x07,0x40,0x00,0xE4,0x00,0x1C,0x00,0x04},/*"A",33*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x04,0x11,0x04,0x0E,0x88,0x00,0x70,0x00,0x00},/*"B",34*/
{0x03,0xE0,0x0C,0x18,0x10,0x04,0x10,0x04,0x10,0x04,0x10,0x08,0x1C,0x10,0x00,0x00},/*"C",35*/
{0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"D",36*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x04,0x17,0xC4,0x10,0x04,0x08,0x18,0x00,0x00},/*"E",37*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x00,0x17,0xC0,0x10,0x00,0x08,0x00,0x00,0x00},/*"F",38*/
{0x03,0xE0,0x0C,0x18,0x10,0x04,0x10,0x04,0x10,0x44,0x1C,0x78,0x00,0x40,0x00,0x00},/*"G",39*/
{0x10,0x04,0x1F,0xFC,0x10,0x84,0x00,0x80,0x00,0x80,0x10,0x84,0x1F,0xFC,0x10,0x04},/*"H",40*/
{0x00,0x00,0x10,0x04,0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x04,0x00,0x00,0x00,0x00},/*"I",41*/
{0x00,0x03,0x00,0x01,0x10,0x01,0x10,0x01,0x1F,0xFE,0x10,0x00,0x10,0x00,0x00,0x00},/*"J",42*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x03,0x80,0x14,0x64,0x18,0x1C,0x10,0x04,0x00,0x00},/*"K",43*/
{0x10,0x04,0x1F,0xFC,0x10,0x04,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x0C,0x00,0x00},/*"L",44*/
{0x10,0x04,0x1F,0xFC,0x1F,0x00,0x00,0xFC,0x1F,0x00,0x1F,0xFC,0x10,0x04,0x00,0x00},/*"M",45*/
{0x10,0x04,0x1F,0xFC,0x0C,0x04,0x03,0x00,0x00,0xE0,0x10,0x18,0x1F,0xFC,0x10,0x00},/*"N",46*/
{0x07,0xF0,0x08,0x08,0x10,0x04,0x10,0x04,0x10,0x04,0x08,0x08,0x07,0xF0,0x00,0x00},/*"O",47*/
{0x10,0x04,0x1F,0xFC,0x10,0x84,0x10,0x80,0x10,0x80,0x10,0x80,0x0F,0x00,0x00,0x00},/*"P",48*/
{0x07,0xF0,0x08,0x18,0x10,0x24,0x10,0x24,0x10,0x1C,0x08,0x0A,0x07,0xF2,0x00,0x00},/*"Q",49*/
{0x10,0x04,0x1F,0xFC,0x11,0x04,0x11,0x00,0x11,0xC0,0x11,0x30,0x0E,0x0C,0x00,0x04},/*"R",50*/
{0x00,0x00,0x0E,0x1C,0x11,0x04,0x10,0x84,0x10,0x84,0x10,0x44,0x1C,0x38,0x00,0x00},/*"S",51*/
{0x18,0x00,0x10,0x00,0x10,0x04,0x1F,0xFC,0x10,0x04,0x10,0x00,0x18,0x00,0x00,0x00},/*"T",52*/
{0x10,0x00,0x1F,0xF8,0x10,0x04,0x00,0x04,0x00,0x04,0x10,0x04,0x1F,0xF8,0x10,0x00},/*"U",53*/
{0x10,0x00,0x1E,0x00,0x11,0xE0,0x00,0x1C,0x00,0x70,0x13,0x80,0x1C,0x00,0x10,0x00},/*"V",54*/
{0x1F,0xC0,0x10,0x3C,0x00,0xE0,0x1F,0x00,0x00,0xE0,0x10,0x3C,0x1F,0xC0,0x00,0x00},/*"W",55*/
{0x10,0x04,0x18,0x0C,0x16,0x34,0x01,0xC0,0x01,0xC0,0x16,0x34,0x18,0x0C,0x10,0x04},/*"X",56*/
{0x10,0x00,0x1C,0x00,0x13,0x04,0x00,0xFC,0x13,0x04,0x1C,0x00,0x10,0x00,0x00,0x00},/*"Y",57*/
{0x08,0x04,0x10,0x1C,0x10,0x64,0x10,0x84,0x13,0x04,0x1C,0x04,0x10,0x18,0x00,0x00},/*"Z",58*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFE,0x40,0x02,0x40,0x02,0x40,0x02,0x00,0x00},/*"[",59*/
{0x00,0x00,0x30,0x00,0x0C,0x00,0x03,0x80,0x00,0x60,0x00,0x1C,0x00,0x03,0x00,0x00},/*"\",60*/
{0x00,0x00,0x40,0x02,0x40,0x02,0x40,0x02,0x7F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00},/*"]",61*/
{0x00,0x00,0x00,0x00,0x20,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x00,0x00},/*"^",62*/
{0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01},/*"_",63*/
{0x00,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"`",64*/
{0x00,0x00,0x00,0x98,0x01,0x24,0x01,0x44,0x01,0x44,0x01,0x44,0x00,0xFC,0x00,0x04},/*"a",65*/
{0x10,0x00,0x1F,0xFC,0x00,0x88,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x70,0x00,0x00},/*"b",66*/
{0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x00},/*"c",67*/
{0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x11,0x08,0x1F,0xFC,0x00,0x04},/*"d",68*/
{0x00,0x00,0x00,0xF8,0x01,0x44,0x01,0x44,0x01,0x44,0x01,0x44,0x00,0xC8,0x00,0x00},/*"e",69*/
{0x00,0x00,0x01,0x04,0x01,0x04,0x0F,0xFC,0x11,0x04,0x11,0x04,0x11,0x00,0x18,0x00},/*"f",70*/
{0x00,0x00,0x00,0xD6,0x01,0x29,0x01,0x29,0x01,0x29,0x01,0xC9,0x01,0x06,0x00,0x00},/*"g",71*/
{0x10,0x04,0x1F,0xFC,0x00,0x84,0x01,0x00,0x01,0x00,0x01,0x04,0x00,0xFC,0x00,0x04},/*"h",72*/
{0x00,0x00,0x01,0x04,0x19,0x04,0x19,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"i",73*/
{0x00,0x00,0x00,0x03,0x00,0x01,0x01,0x01,0x19,0x01,0x19,0xFE,0x00,0x00,0x00,0x00},/*"j",74*/
{0x10,0x04,0x1F,0xFC,0x00,0x24,0x00,0x40,0x01,0xB4,0x01,0x0C,0x01,0x04,0x00,0x00},/*"k",75*/
{0x00,0x00,0x10,0x04,0x10,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00},/*"l",76*/
{0x01,0x04,0x01,0xFC,0x01,0x04,0x01,0x00,0x01,0xFC,0x01,0x04,0x01,0x00,0x00,0xFC},/*"m",77*/
{0x01,0x04,0x01,0xFC,0x00,0x84,0x01,0x00,0x01,0x00,0x01,0x04,0x00,0xFC,0x00,0x04},/*"n",78*/
{0x00,0x00,0x00,0xF8,0x01,0x04,0x01,0x04,0x01,0x04,0x01,0x04,0x00,0xF8,0x00,0x00},/*"o",79*/
{0x01,0x01,0x01,0xFF,0x00,0x85,0x01,0x04,0x01,0x04,0x00,0x88,0x00,0x70,0x00,0x00},/*"p",80*/
{0x00,0x00,0x00,0x70,0x00,0x88,0x01,0x04,0x01,0x04,0x01,0x05,0x01,0xFF,0x00,0x01},/*"q",81*/
{0x01,0x04,0x01,0x04,0x01,0xFC,0x00,0x84,0x01,0x04,0x01,0x00,0x01,0x80,0x00,0x00},/*"r",82*/
{0x00,0x00,0x00,0xCC,0x01,0x24,0x01,0x24,0x01,0x24,0x01,0x24,0x01,0x98,0x00,0x00},/*"s",83*/
{0x00,0x00,0x01,0x00,0x01,0x00,0x07,0xF8,0x01,0x04,0x01,0x04,0x00,0x00,0x00,0x00},/*"t",84*/
{0x01,0x00,0x01,0xF8,0x00,0x04,0x00,0x04,0x00,0x04,0x01,0x08,0x01,0xFC,0x00,0x04},/*"u",85*/
{0x01,0x00,0x01,0x80,0x01,0x70,0x00,0x0C,0x00,0x10,0x01,0x60,0x01,0x80,0x01,0x00},/*"v",86*/
{0x01,0xF0,0x01,0x0C,0x00,0x30,0x01,0xC0,0x00,0x30,0x01,0x0C,0x01,0xF0,0x01,0x00},/*"w",87*/
{0x00,0x00,0x01,0x04,0x01,0x8C,0x00,0x74,0x01,0x70,0x01,0x8C,0x01,0x04,0x00,0x00},/*"x",88*/
{0x01,0x01,0x01,0x81,0x01,0x71,0x00,0x0E,0x00,0x18,0x01,0x60,0x01,0x80,0x01,0x00},/*"y",89*/
{0x00,0x00,0x01,0x84,0x01,0x0C,0x01,0x34,0x01,0x44,0x01,0x84,0x01,0x0C,0x00,0x00},/*"z",90*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x3E,0xFC,0x40,0x02,0x40,0x02},/*"{",91*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00},/*"|",92*/
{0x00,0x00,0x40,0x02,0x40,0x02,0x3E,0xFC,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"}",93*/
{0x00,0x00,0x60,0x00,0x80,0x00,0x80,0x00,0x40,0x00,0x40,0x00,0x20,0x00,0x20,0x00},/*"~",94*/
};
static const unsigned char Font1612[11][32] =
{
{0x00,0x00,0x3F,0xFC,0x3F,0xFC,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,
0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"0",0*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,
0x30,0x00,0x3F,0xFC,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*"1",1*/
{0x00,0x00,0x39,0xFC,0x39,0xFC,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,
0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x3F,0x8C,0x3F,0x8C,0x00,0x00},/*"2",2*/
{0x00,0x00,0x38,0x1C,0x38,0x1C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,
0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"3",3*/
{0x00,0x00,0x3F,0x80,0x3F,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,
0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x01,0x80,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"4",4*/
{0x00,0x00,0x3F,0xBC,0x3F,0xBC,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,
0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0xFC,0x31,0xFC,0x00,0x00},/*"5",5*/
{0x00,0x00,0x3F,0x9C,0x3F,0x9C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,
0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0xFC,0x31,0xFC,0x00,0x00},/*"6",6*/
{0x00,0x00,0x38,0x00,0x38,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,
0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"7",7*/
{0x00,0x00,0x3F,0xFC,0x3F,0xFC,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,
0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"8",8*/
{0x00,0x00,0x3F,0x9C,0x3F,0x9C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,
0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x31,0x8C,0x3F,0xFC,0x3F,0xFC,0x00,0x00},/*"9",9*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x30,
0x18,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*":",10*/
};
static const unsigned char Font3216[11][64] =
{
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC, /*"0",0*/
0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,
0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,0x30,0x00,0x00,0x0C,
0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*"1",1*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x01,0xFF,0xFC,0x3C,0x01,0xFF,0xFC, /*"2",2*/
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x3F,0xFF,0x80,0x0C,0x3F,0xFF,0x80,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,0x3C,0x38,0x00,0x00,0x3C, /*"3",3*/
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x80,0x00,0x3F,0xFF,0x80,0x00, /*"4",4*/
0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,
0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,0x00,0x01,0x80,0x00,
0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x80,0x3C,0x3F,0xFF,0x80,0x3C, /*"5",5*/
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x30,0x01,0xFF,0xFC,0x30,0x01,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC, /*"6",6*/
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x3C,0x01,0xFF,0xFC,0x3C,0x01,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x00,0x00,0x00,0x3C,0x00,0x00,0x00, /*"7",7*/
0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC, /*"8",8*/
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFF,0x80,0x3C,0x3F,0xFF,0x80,0x3C, /*"9",9*/
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,0x30,0x01,0x80,0x0C,
0x3F,0xFF,0xFF,0xFC,0x3F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /*":",10*/
0x00,0x00,0x00,0x00,0x0F,0xF0,0x0F,0xF0,0x0F,0xF0,0x0F,0xF0,0x0C,0x00,0x00,0x30,
0x0C,0x00,0x00,0x30,0x0F,0xF0,0x0F,0xF0,0x0F,0xF0,0x0F,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
};
static const unsigned char Bmp4016[96] = //SUN
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xF1,0x81,0x8F,0xFC,0x3F,
0xF1,0x81,0x8F,0xFC,0x30,0x31,0x81,0x8C,0x0C,0x30,0x01,0x81,0x8C,0x0C,0x30,0x01,
0x81,0x8C,0x0C,0x3F,0xF1,0x81,0x8C,0x0C,0x3F,0xF1,0x81,0x8C,0x0C,0x00,0x31,0x81,
0x8C,0x0C,0x00,0x31,0x81,0x8C,0x0C,0x30,0x31,0x81,0x8C,0x0C,0x3F,0xF1,0xFF,0x8C,
0x0C,0x3F,0xF1,0xFF,0x8C,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
static const unsigned char Singal816[16] = //mobie singal
{
0xFE,0x02,0x92,0x0A,0x54,0x2A,0x38,0xAA,0x12,0xAA,0x12,0xAA,0x12,0xAA,0x12,0xAA
};
static const unsigned char Msg816[16] = //message
{
0x1F,0xF8,0x10,0x08,0x18,0x18,0x14,0x28,0x13,0xC8,0x10,0x08,0x10,0x08,0x1F,0xF8
};
static const unsigned char Bat816[16] = //batery
{
0x0F,0xFE,0x30,0x02,0x26,0xDA,0x26,0xDA,0x26,0xDA,0x26,0xDA,0x30,0x02,0x0F,0xFE
};
static const unsigned char Bluetooth88[8] = // bluetooth
{
0x18,0x54,0x32,0x1C,0x1C,0x32,0x54,0x18
};
static const unsigned char GPRS88[8] = //GPRS
{
0xC3,0x99,0x24,0x20,0x2C,0x24,0x99,0xC3
};
static const unsigned char Alarm88[8] = //alram
{
0xC3,0xBD,0x42,0x52,0x4E,0x42,0x3C,0xC3
};
#endif

View File

@ -0,0 +1,49 @@
#include <wiringPi.h>
#include <wiringPiSPI.h>
#include <stdio.h>
#include <time.h>
#include "SSD1306.h"
char value[10]={'0','1','2','3','4','5','6','7','8','9'};
int main(int argc,char **argv)
{
time_t now;
struct tm *timenow;
if(wiringPiSetup() < 0)return 1;
printf("OLED Test Program !!!\n");
SSD1306_begin();
SSD1306_bitmap(0,0,waveshare,128,64);
SSD1306_display();
delay(2000);
SSD1306_clear();
while(1)
{
time(&now);
timenow = localtime(&now);
SSD1306_bitmap(0, 2, Singal816, 16, 8);
SSD1306_bitmap(24, 2,Bluetooth88, 8, 8);
SSD1306_bitmap(40, 2, Msg816, 16, 8);
SSD1306_bitmap(64, 2, GPRS88, 8, 8);
SSD1306_bitmap(90, 2, Alarm88, 8, 8);
SSD1306_bitmap(112, 2, Bat816, 16, 8);
SSD1306_string(0, 52, "MUSIC", 12, 0);
SSD1306_string(52, 52, "MENU", 12, 0);
SSD1306_string(98, 52, "PHONE", 12, 0);
SSD1306_char3216(0,16, value[timenow->tm_hour/10]);
SSD1306_char3216(16,16, value[timenow->tm_hour%10]);
SSD1306_char3216(32,16, ':');
SSD1306_char3216(48,16, value[timenow->tm_min/10]);
SSD1306_char3216(64,16, value[timenow->tm_min%10]);
SSD1306_char3216(80,16, ':');
SSD1306_char3216(96,16, value[timenow->tm_sec/10]);
SSD1306_char3216(112,16, value[timenow->tm_sec%10]);
SSD1306_display();
}
return 0;
}

View File

@ -0,0 +1,6 @@
pcf8574:pcf8574.c
gcc -Wall pcf8574.c -o pcf8574 -lbcm2835
gcc -Wall led.c -o led -lbcm2835
clean:
rm pcf8574 led

View File

@ -0,0 +1,25 @@
#include <bcm2835.h>
int main(int argc, char **argv)
{
char buf[1];
if (!bcm2835_init())return 1;
bcm2835_i2c_begin();
bcm2835_i2c_setSlaveAddress(0x20); //i2c address
bcm2835_i2c_set_baudrate(10000); //1M baudrate
while(1)
{
buf[0] = 0xEF; //LED ON
bcm2835_i2c_write(buf,1);
bcm2835_delay(500);
buf[0] = 0xFF; //LED OFF
bcm2835_i2c_write(buf,1);
bcm2835_delay(500);
}
bcm2835_i2c_end();
bcm2835_close();
return 0;
}

View File

@ -0,0 +1,65 @@
#include <bcm2835.h>
#include <stdio.h>
#define beep_on i2c_writeByte(0x7F & i2c_readByte())
#define beep_off i2c_writeByte(0x80 | i2c_readByte())
#define led_off i2c_writeByte(0x10 | i2c_readByte())
#define led_on i2c_writeByte(0xEF & i2c_readByte())
void i2c_writeByte(char byte)
{
char buf[] = {byte};
bcm2835_i2c_write(buf,1);
}
char i2c_readByte()
{
char buf[1];
bcm2835_i2c_read(buf,1);
return buf[0];
}
int main(int argc, char **argv)
{
char value;
if (!bcm2835_init())return 1;
bcm2835_i2c_begin();
bcm2835_i2c_setSlaveAddress(0x20);
bcm2835_i2c_set_baudrate(10000);
printf("PCF8574 Test Program !!!\n");
while(1)
{
i2c_writeByte(0x0F | i2c_readByte());
value = i2c_readByte() | 0xF0;
if(value != 0xFF)
{
beep_on;
led_on;
switch(value)
{
case 0xFE:
printf("left\n");break;
case 0xFD:
printf("up\n"); break;
case 0xFB:
printf("dowm\n");break;
case 0xF7:
printf("right\n");break;
default :
printf("unknow\n");
}
while(value != 0xFF)
{
i2c_writeByte(0x0F | i2c_readByte());
value = i2c_readByte() | 0xF0;
bcm2835_delay(10);
}
beep_off;
led_off;
}
bcm2835_delay(10);
}
bcm2835_i2c_end();
bcm2835_close();
return 0;
}

View File

@ -0,0 +1,5 @@
led:led.c
gcc led.c -o led
clean:
rm led

View File

@ -0,0 +1,35 @@
#include <stdio.h>
#include <fcntl.h>
#include <linux/i2c-dev.h>
#include <errno.h>
#define I2C_ADDR 0x20
#define LED_ON 0xEF
#define LED_OFF 0xFF
int main (void) {
int value;
int fd;
// opend device,i2c-1
fd = open("/dev/i2c-1", O_RDWR);
if (fd < 0) {
printf("Error opening file: %s\n", strerror(errno));
return 1;
}
// set I2C address
if (ioctl(fd, I2C_SLAVE, I2C_ADDR) < 0) {
printf("ioctl error: %s\n", strerror(errno));
return 1;
}
while(1)
{
// write byte to PCF8574
if(value == LED_ON)value = LED_OFF;
else value = LED_ON;
if( write( fd , &value, 1 ) != 1) {
printf("Error writing file: %s\n", strerror(errno));
}
usleep(1000000);
}
return 0;
}

View File

@ -0,0 +1,13 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
import smbus
import time
address = 0x20
bus = smbus.SMBus(1)
while True:
bus.write_byte(address,0xEF)
time.sleep(0.5)
bus.write_byte(address,0xFF)
time.sleep(0.5)

View File

@ -0,0 +1,42 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
import RPi.GPIO as GPIO
import smbus
import time
address = 0x20
def beep_on():
bus.write_byte(address,0x7F&bus.read_byte(address))
def beep_off():
bus.write_byte(address,0x80|bus.read_byte(address))
def led_off():
bus.write_byte(address,0x10|bus.read_byte(address))
def led_on():
bus.write_byte(address,0xEF&bus.read_byte(address))
bus = smbus.SMBus(1)
print("PCF8574 Test Program !!!")
while True:
bus.write_byte(address,0x0F|bus.read_byte(address))
value = bus.read_byte(address) | 0xF0
if value != 0xFF:
led_on()
beep_on()
if (value | 0xFE) != 0xFF:
print("left")
elif (value | 0xFD) != 0xFF:
print("up")
elif (value | 0xFB) != 0xFF:
print("dowm")
else :
print("right")
while value != 0xFF:
bus.write_byte(address,0x0F|bus.read_byte(address))
value = bus.read_byte(address) | 0xF0
time.sleep(0.01)
beep_off()
led_off()
time.sleep(0.1)

View File

@ -0,0 +1,6 @@
led:led.c
gcc -Wall led.c -o led -lwiringPi
gcc -Wall PCF8574.c -o PCF8574 -lwiringPi
clean:
rm led PCF8574

View File

@ -0,0 +1,62 @@
#include <wiringPi.h>
#include <wiringPiI2C.h>
#include <stdio.h>
#define PCF8574_Address 0x20
#define beep_on i2c_writeByte(0x7F & i2c_readByte())
#define beep_off i2c_writeByte(0x80 | i2c_readByte())
#define led_off i2c_writeByte(0x10 | i2c_readByte())
#define led_on i2c_writeByte(0xEF & i2c_readByte())
int fd;
void i2c_writeByte(char byte)
{
wiringPiI2CWrite(fd,byte);
}
char i2c_readByte()
{
return (char)wiringPiI2CRead(fd);
}
int main()
{
char value;
if (wiringPiSetup() < 0)return 1;
fd = wiringPiI2CSetup(PCF8574_Address);
printf("PCF8574 Test Program !!!\n");
while(1)
{
i2c_writeByte(0x0F | i2c_readByte());
value = i2c_readByte() | 0xF0;
if(value != 0xFF)
{
beep_on;
led_on;
switch(value)
{
case 0xFE:
printf("left\n");break;
case 0xFD:
printf("up\n"); break;
case 0xFB:
printf("dowm\n");break;
case 0xF7:
printf("right\n");break;
default :
printf("unknow\n");
}
while(value != 0xFF)
{
i2c_writeByte(0x0F | i2c_readByte());
value = i2c_readByte() | 0xF0;
delay(10);
}
beep_off;
led_off;
}
delay(10);
}
}

View File

@ -0,0 +1,21 @@
#include <stdio.h>
#include <wiringPi.h>
#include <pcf8574.h>
#define EXTEND_BASE 64
#define LED EXTEND_BASE + 4
int main (void)
{
wiringPiSetup();
pcf8574Setup(EXTEND_BASE,0x20);
pinMode(LED,OUTPUT);
while (1)
{
digitalWrite(LED,LOW); //LED ON
delay(500);
digitalWrite(LED,HIGH); //LED OFF
delay(500);
}
return 0;
}

View File

@ -0,0 +1,5 @@
pcf8591:pcf8591.c
gcc -Wall pcf8591.c -o pcf8591 -lbcm2835
clean:
rm pcf8591

View File

@ -0,0 +1,32 @@
#include <bcm2835.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv)
{
char Buf[]={0};
unsigned char i;
if (!bcm2835_init())return 1;
bcm2835_i2c_begin();
bcm2835_i2c_setSlaveAddress(0x48);
bcm2835_i2c_set_baudrate(10000);
printf("start..........\n");
while(1)
{
for(i = 0;i < 4;i++)
{
Buf[0] = i;
bcm2835_i2c_write_read_rs(Buf,1,Buf,1);
bcm2835_i2c_read (Buf,1);
printf("AIN%d:%5.2f ",i,(double)Buf[0]*3.3/255);
}
printf("\n");
bcm2835_delay(100);
}
bcm2835_i2c_end();
bcm2835_close();
return 0;
}

View File

@ -0,0 +1,18 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
import smbus
import time
address = 0x48
A0 = 0x40
A1 = 0x41
A2 = 0xA2
A3 = 0xA3
bus = smbus.SMBus(1)
while True:
bus.write_byte(address,A0)
value = bus.read_byte(address)
print("AOUT:%1.3f " %(value*3.3/255))
time.sleep(0.1)

View File

@ -0,0 +1,5 @@
pcf8591:pcf8591.c
gcc -Wall pcf8591.c -o pcf8591 -lwiringPi
clean:
rm pcf8591

View File

@ -0,0 +1,25 @@
#include <wiringPi.h>
#include <pcf8591.h>
#include <stdio.h>
#define Address 0x48
#define BASE 64
#define A0 BASE+0
#define A1 BASE+1
#define A2 BASE+2
#define A3 BASE+3
int main(void)
{
int value;
wiringPiSetup();
pcf8591Setup(BASE,Address);
while(1)
{
value = analogRead(A0);
printf("Analoge: %dmv\n",value*3300/255);
delay(1000);
}
}

View File

@ -0,0 +1,5 @@
pcf8591:pcf8591.c
gcc -Wall pcf8591.c -o pcf8591 -lbcm2835
clean:
rm pcf8591

View File

@ -0,0 +1,29 @@
#include <bcm2835.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv)
{
char Buf[]={0,0};
unsigned char value=0;
if (!bcm2835_init())return 1;
bcm2835_i2c_begin();
bcm2835_i2c_setSlaveAddress(0x48);
bcm2835_i2c_set_baudrate(10000);
printf("start..........\n");
while(1)
{
Buf[0] = 0x40;
Buf[1] = value++;
bcm2835_i2c_write(Buf,2);
printf("AOUT: %d\n",value);
bcm2835_delay(20);
}
bcm2835_i2c_end();
bcm2835_close();
return 0;
}

View File

@ -0,0 +1,19 @@
#!/usr/bin/python
# -*- coding:utf-8 -*-
import smbus
import time
address = 0x48
cmd = 0x40
value = 0
bus = smbus.SMBus(1)
while True:
bus.write_byte_data(address,cmd,value)
value += 1
if value == 256:
value =0
print("AOUT:%3d" %value)
time.sleep(0.01)

View File

@ -0,0 +1,5 @@
pcf8591:pcf8591.c
gcc -Wall pcf8591.c -o pcf8591 -lwiringPi
clean:
rm pcf8591

View File

@ -0,0 +1,25 @@
#include <wiringPi.h>
#include <pcf8591.h>
#include <stdio.h>
#define Address 0x48
#define BASE 64
#define A0 BASE+0
#define A1 BASE+1
#define A2 BASE+2
#define A3 BASE+3
int main(void)
{
unsigned char value;
wiringPiSetup();
pcf8591Setup(BASE,Address);
while(1)
{
analogWrite(A0,value);
printf("AOUT: %d\n",value++);
delay(20);
}
}

View File

@ -0,0 +1,125 @@
#include <stdio.h>
#include <wiringPi.h>
#define u8 unsigned char
#define u16 unsigned int
#define Din 0
#define S3 21
#define S2 22
#define S1 23
#define S0 26
// the event counter
int g_count = 0; // count the frequecy
int g_array[3]; // store the RGB value
int g_flag = 0; // filter of RGB queue
float g_SF[3]; // save the RGB Scale factor
// Select the filter color
void TSC_FilterColor(int Level01, int Level02)
{
if(Level01 != 0)
Level01 = HIGH;
if(Level02 != 0)
Level02 = HIGH;
digitalWrite(S2, Level01);
digitalWrite(S3, Level02);
}
void TSC_WB(int Level0, int Level1) //White Balance
{
g_count = 0;
g_flag ++;
TSC_FilterColor(Level0, Level1);
}
PI_THREAD(myThread)
{
while(1)
{
delay(1000);
switch(g_flag)
{
case 0:
printf("->WB Start\n");
TSC_WB(LOW, LOW); //Filter without Red
break;
case 1:
printf("->Frequency R=%ld\n",g_count);
g_array[0] = g_count;
TSC_WB(HIGH, HIGH); //Filter without Green
break;
case 2:
printf("->Frequency G=%ld\n",g_count);
g_array[1] = g_count;
TSC_WB(LOW, HIGH); //Filter without Blue
break;
case 3:
printf("->Frequency B=%ld\n",g_count);
printf("->WB End\n");
g_array[2] = g_count;
TSC_WB(HIGH, LOW); //Clear(no filter)
break;
default:
g_count = 0;
break;
}
}
}
void myInterrupt(void) {
g_count ++ ;
}
int main(void)
{
unsigned int i;
if(wiringPiSetup() < 0)return 1;
if(wiringPiISR (Din, INT_EDGE_FALLING, &myInterrupt) < 0 )
{
printf("Unable to setup ISR\n");
return 1;
}
int x = piThreadCreate (myThread) ;
if (x != 0)printf("it didn't start\n");
pinMode(S0,OUTPUT);
pinMode(S1,OUTPUT);
pinMode(S2,OUTPUT);
pinMode(S3,OUTPUT);
digitalWrite(S0, LOW); // OUTPUT FREQUENCY SCALING 2%
digitalWrite(S1, HIGH);
delay(5000);
printf("R:%ld\n",g_array[0]);
printf("G:%ld\n",g_array[1]);
printf("B:%ld\n",g_array[2]);
g_SF[0] = 255.0/ g_array[0]; //R Scale factor
g_SF[1] = 255.0/ g_array[1] ; //G Scale factor
g_SF[2] = 255.0/ g_array[2] ; //B Scale factor
printf("R:%f\n",g_SF[0]);
printf("G:%f\n",g_SF[1]);
printf("B:%f\n",g_SF[2]);
while(1)
{
g_flag = 0;
printf("R:%ld\n",(int)(g_array[0]*g_SF[0]));
printf("G:%ld\n",(int)(g_array[1]*g_SF[1]));
printf("B:%ld\n",(int)(g_array[2]*g_SF[2]));
delay(5000);
}
return 0;
}

View File

@ -0,0 +1,4 @@
Color_Sensor:Color_Sensor.c
gcc Color_Sensor.c -o Color_Sensor -lwiringPi -lpthread
clean:Color_Sensor
rm Color_Sensor

View File

@ -0,0 +1,32 @@
#include <wiringPi.h>
#include <pcf8591.h>
#include <stdio.h>
#define Address 0x48
#define BASE 64
#define A0 BASE+0
#define A1 BASE+1
#define A2 BASE+2
#define A3 BASE+3
#define D3 26
int main()
{
if (wiringPiSetup() < 0)return 1;
pcf8591Setup(BASE,Address);
pinMode(D3,INPUT);
while(1)
{
if(digitalRead(D3) == LOW)
{
printf("Near the flame!\n");
printf("AD: %04dmv \n",analogRead(A3)*3300/255);
}
else
{
printf("Far the flame!\n");
}
delay(500);
}
}

View File

@ -0,0 +1,5 @@
tlc1543:General_Sensor.c
gcc -Wall General_Sensor.c -o General_Sensor -lwiringPi
clean:General_Sensor
rm General_Sensor

View File

@ -0,0 +1,32 @@
#include <wiringPi.h>
#include <pcf8591.h>
#include <stdio.h>
#define Address 0x48
#define BASE 64
#define A0 BASE+0
#define A1 BASE+1
#define A2 BASE+2
#define A3 BASE+3
#define D3 26
int main()
{
if (wiringPiSetup() < 0)return 1;
pcf8591Setup(BASE,Address);
pinMode(D3,INPUT);
while(1)
{
if(digitalRead(D3) == LOW)
{
printf("Near Field !!!\n");
printf("AD: %04dmv \n",analogRead(A3)*3300/255);
}
else
{
printf("Far Field\n");
}
delay(100);
}
}

View File

@ -0,0 +1,5 @@
tlc1543:General_Sensor.c
gcc -Wall General_Sensor.c -o General_Sensor -lwiringPi
clean:General_Sensor
rm General_Sensor

View File

@ -0,0 +1,33 @@
#include <wiringPi.h>
#include <pcf8591.h>
#include <stdio.h>
#define Address 0x48
#define BASE 64
#define A0 BASE+0
#define A1 BASE+1
#define A2 BASE+2
#define A3 BASE+3
#define D3 26
int main()
{
if (wiringPiSetup() < 0)return 1;
pcf8591Setup(BASE,Address);
pinMode(D3,INPUT);
digitalWrite(D3,0);
while(1)
{
if(digitalRead(D3) == LOW)
{
printf("Near the Obstacles\n");
printf("AD: %04dmv \n",analogRead(A3)*3300/255);
}
else
{
printf("Far the Obstacles\n");
}
delay(500);
}
}

View File

@ -0,0 +1,5 @@
tlc1543:General_Sensor.c
gcc -Wall General_Sensor.c -o General_Sensor -lwiringPi
clean:General_Sensor
rm General_Sensor

View File

@ -0,0 +1,25 @@
#include <stdio.h>
#include<wiringPi.h>
#define D3 26
int main()
{
if (wiringPiSetup() < 0)return 1 ;
pinMode(D3,INPUT);
digitalWrite(D3,0);
while(1)
{
if(digitalRead(D3) == LOW)
{
printf("Obstacles\n");
}
else
{
printf("No Obstacles\n");
}
delay(500);
}
}

View File

@ -0,0 +1,5 @@
tlc1543:General_Sensor.c
gcc -Wall General_Sensor.c -o General_Sensor -lwiringPi
clean:General_Sensor
rm General_Sensor

View File

@ -0,0 +1,22 @@
#include <wiringPi.h>
#include <pcf8591.h>
#include <stdio.h>
#define Address 0x48
#define BASE 64
#define A0 BASE+0
#define A1 BASE+1
#define A2 BASE+2
#define A3 BASE+3
int main()
{
if (wiringPiSetup() < 0)return 1;
pcf8591Setup(BASE,Address);
while(1)
{
printf("AD: %4dmv \n",analogRead(A3)*3300/255);
delay(1000);
}
}

View File

@ -0,0 +1,5 @@
tlc1543:General_Sensor.c
gcc -Wall General_Sensor.c -o General_Sensor -lwiringPi
clean:General_Sensor
rm General_Sensor

View File

@ -0,0 +1,33 @@
#include <wiringPi.h>
#include <pcf8591.h>
#include <stdio.h>
#define Address 0x48
#define BASE 64
#define A0 BASE+0
#define A1 BASE+1
#define A2 BASE+2
#define A3 BASE+3
#define D3 26
int main()
{
if (wiringPiSetup() < 0)return 1;
pcf8591Setup(BASE,Address);
pinMode(D3,INPUT);
//digitalWrite(D3,0);
while(1)
{
if(digitalRead(D3) == LOW)
{
printf("Gas leakage\n");
printf("AD: %04d \n",analogRead(A3)*3300/255);
}
else
{
printf("Gas not leakage\n");
}
delay(500);
}
}

View File

@ -0,0 +1,5 @@
tlc1543:General_Sensor.c
gcc -Wall General_Sensor.c -o General_Sensor -lwiringPi
clean:General_Sensor
rm General_Sensor

View File

@ -0,0 +1,32 @@
#include <wiringPi.h>
#include <pcf8591.h>
#include <stdio.h>
#define Address 0x48
#define BASE 64
#define A0 BASE+0
#define A1 BASE+1
#define A2 BASE+2
#define A3 BASE+3
#define D3 26
int main()
{
if (wiringPiSetup() < 0)return 1;
pcf8591Setup(BASE,Address);
pinMode(D3,INPUT);
while(1)
{
if(digitalRead(D3) == LOW)
{
printf("Touch the metal!\n");
printf("AD: %04dmv \n",analogRead(A3)*3300/255);
}
else
{
printf("Not touch the metal!\n");
}
delay(500);
}
}

View File

@ -0,0 +1,5 @@
tlc1543:General_Sensor.c
gcc -Wall General_Sensor.c -o General_Sensor -lwiringPi
clean:General_Sensor
rm General_Sensor

View File

@ -0,0 +1,22 @@
#include <wiringPi.h>
#include <pcf8591.h>
#include <stdio.h>
#define Address 0x48
#define BASE 64
#define A0 BASE+0
#define A1 BASE+1
#define A2 BASE+2
#define A3 BASE+3
int main()
{
if (wiringPiSetup() < 0)return 1;
pcf8591Setup(BASE,Address);
while(1)
{
printf("AD: %4dmv \n",analogRead(A3)*3300/255);
delay(1000);
}
}

View File

@ -0,0 +1,5 @@
tlc1543:General_Sensor.c
gcc -Wall General_Sensor.c -o General_Sensor -lwiringPi
clean:General_Sensor
rm General_Sensor

View File

@ -0,0 +1,4 @@
Rotation_Sensor:Rotation_Sensor.c
gcc -Wall Rotation_Sensor.c -o Rotation_Sensor -lwiringPi
clean:Rotation
rm Rotation

View File

@ -0,0 +1,58 @@
#include <stdio.h>
#include <wiringPi.h>
#define SIA 22
#define SIB 23
#define SW 26
char turn_flag;
// myInterrupt: called every time an event occurs
void myInterrupt0(void) {
turn_flag=1;
}
void myInterrupt1(void) {
turn_flag=2;
}
void myInterrupt2(void) {
turn_flag=3;
}
int main(void)
{
if(wiringPiSetup () < 0) return 1;
if(wiringPiISR(SIA, INT_EDGE_BOTH, &myInterrupt0) < 0 )
{
printf("Unable to setup ISR: SIA\n");
return 1;
}
if(wiringPiISR(SIB, INT_EDGE_BOTH, &myInterrupt1) < 0 )
{
printf("Unable to setup ISR: SIB\n");
return 1;
}
if(wiringPiISR(SW, INT_EDGE_FALLING, &myInterrupt2) < 0 )
{
printf("Unable to setup ISR: SW\n");
return 1;
}
while (1)
{
if(turn_flag)
{
switch(turn_flag)
{
case 1: printf("Turn right!\r\n");break;
case 2: printf("Turn left!\r\n");break;
case 3: printf("Turn down!\r\n");break;
default:break;
}
delay(500);
turn_flag=0;
}
}
return 0;
}

View File

@ -0,0 +1,32 @@
#include <wiringPi.h>
#include <pcf8591.h>
#include <stdio.h>
#define Address 0x48
#define BASE 64
#define A0 BASE+0
#define A1 BASE+1
#define A2 BASE+2
#define A3 BASE+3
#define D3 26
int main()
{
if (wiringPiSetup() < 0)return 1;
pcf8591Setup(BASE,Address);
pinMode(D3,INPUT);
while(1)
{
if(digitalRead(D3) == LOW)
{
printf("Noise !!!\n");
printf("AD: %04dmv \n",analogRead(A3)*3300/255);
}
else
{
printf("Quiet\n");
}
delay(100);
}
}

View File

@ -0,0 +1,5 @@
tlc1543:General_Sensor.c
gcc -Wall General_Sensor.c -o General_Sensor -lwiringPi
clean:General_Sensor
rm General_Sensor

View File

@ -0,0 +1,87 @@
#include <stdio.h>
#include<wiringPi.h>
#define Data 26
char DHT11_Read(char *temperature,char *humidity)
{
unsigned char t,i,j;
unsigned char buf[5]={0,0,0,0,0};
pinMode(Data,OUTPUT); //SET OUTPUT
pullUpDnControl(Data,PUD_UP);
digitalWrite(Data,0); //Data=0
delay(20); //Pull down Least 18ms
digitalWrite(Data,1); //Data =1
delayMicroseconds(30); //Pull up 20~40us
pinMode(Data,INPUT); //SET INPUT
while (digitalRead(Data) && t <100)//DHT11 Pull down 80us
{
t++;
delayMicroseconds(1);
};
if(t >= 100)return 1;
t = 0;
while (!digitalRead(Data) && t<100)//DHT11 Pull up 80us
{
t++;
delayMicroseconds(1);
};
if(t >= 100)return 1;
for(i=0;i < 5;i++)
{
buf[i] = 0;
for(j=0;j<8;j++)
{
buf[i] <<= 1;
t = 0;
while(digitalRead(Data) && t < 100)
{
t++;
delayMicroseconds(1);
}
if(t >= 100) return 1;
t = 0;
while(!digitalRead(Data) && t <100)
{
t++;
delayMicroseconds(1);
}
if(t >= 100) return 1;
delayMicroseconds(40);
if(digitalRead(Data))
buf[i] += 1;
}
}
if(buf[0]+buf[1]+buf[2]+buf[3]!=buf[4])return 2;
*humidity = buf[0];
*temperature =buf[2];
return 0;
}
int main(void)
{
char temperature;
char humidity;
char value;
if (wiringPiSetup() < 0)return 1;
printf("Waveshare!\r\n");
while(1)
{
value = DHT11_Read(&temperature,&humidity);
if(value == 0)
{
printf("\ntemperature = %d\r\n",temperature);
printf("humidity = %d\r\n",humidity);
}
else if (value == 2)
printf("\ncheck sum err\n");
else
printf("\ntime out\n");
delay(1000);
}
}

View File

@ -0,0 +1,4 @@
DHT11:DHT11.c
gcc -Wall DHT11.c -o DHT11 -lwiringPi
clean:DHT11
rm DHT11

View File

@ -0,0 +1,25 @@
#include <stdio.h>
#include<wiringPi.h>
#define D3 26
int main()
{
if (wiringPiSetup() < 0)return 1 ;
pinMode(D3,INPUT);
digitalWrite(D3,0);
while(1)
{
if(digitalRead(D3) == LOW)
{
printf("Tilt\n");
}
else
{
printf("OK\n");
}
delay(500);
}
}

Some files were not shown because too many files have changed in this diff Show More