Updated state machine and some clean-up
This commit is contained in:
@@ -23,6 +23,7 @@ BuckConverter::BuckConverter(int freq_kHz)
|
||||
last_time_CV_reset();
|
||||
|
||||
_pwm_delta = 1;
|
||||
_enabled = false;
|
||||
}
|
||||
|
||||
void BuckConverter::update(int input_voltage_mV, int output_voltage_mV, int output_current_mA) {
|
||||
@@ -33,10 +34,22 @@ void BuckConverter::update(int input_voltage_mV, int output_voltage_mV, int outp
|
||||
|
||||
if (output_voltage_mV > _max_voltage_mV) {
|
||||
// increase input voltage to lower output voltage
|
||||
duty_cycle_step(-1);
|
||||
_time_voltage_limit_reached = time(NULL);
|
||||
if (output_current_mA > _min_current_mA) {
|
||||
duty_cycle_step(-1);
|
||||
_time_voltage_limit_reached = time(NULL);
|
||||
}
|
||||
else {
|
||||
// switch off and wait for voltage to go down
|
||||
// (otherwise current could get negative, i.e. into solar panel)
|
||||
TIM1->BDTR &= ~(TIM_BDTR_MOE);
|
||||
}
|
||||
//printf("output_voltage_mV = %d, _max_voltage_mV = %d\n", output_voltage_mV, _max_voltage_mV);
|
||||
fflush(stdout);
|
||||
//fflush(stdout);
|
||||
}
|
||||
else if (~(TIM1->BDTR & TIM_BDTR_MOE) && _enabled == true) {
|
||||
// switched off because of too high output voltage?
|
||||
// now: output_voltage_mV <= _max_voltage_mV --> start again
|
||||
start((float) output_voltage_mV / (input_voltage_mV - 1000.0));
|
||||
}
|
||||
else if (output_current_mA > _max_current_mA) {
|
||||
// increase input voltage to decrease current
|
||||
@@ -99,14 +112,18 @@ void BuckConverter::init_registers() {
|
||||
TIM1->EGR |= TIM_EGR_UG;
|
||||
}
|
||||
|
||||
void BuckConverter::set_voltage_limit(int voltage_mV) {
|
||||
void BuckConverter::set_max_voltage(int voltage_mV) {
|
||||
_max_voltage_mV = voltage_mV;
|
||||
}
|
||||
|
||||
void BuckConverter::set_current_limit(int current_mA) {
|
||||
void BuckConverter::set_max_current(int current_mA) {
|
||||
_max_current_mA = current_mA;
|
||||
}
|
||||
|
||||
void BuckConverter::set_min_current(int current_mA) {
|
||||
_min_current_mA = current_mA;
|
||||
}
|
||||
|
||||
time_t BuckConverter::last_time_CV() {
|
||||
return _time_voltage_limit_reached;
|
||||
}
|
||||
@@ -183,6 +200,8 @@ void BuckConverter::start(float pwm_duty) {
|
||||
// Break and Dead-Time Register
|
||||
// MOE = 1: Main output enable
|
||||
TIM1->BDTR |= TIM_BDTR_MOE;
|
||||
|
||||
_enabled = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -191,6 +210,8 @@ void BuckConverter::stop() {
|
||||
// Break and Dead-Time Register
|
||||
// MOE = 1: Main output enable
|
||||
TIM1->BDTR &= ~(TIM_BDTR_MOE);
|
||||
|
||||
_enabled = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,8 +24,9 @@ public:
|
||||
*/
|
||||
BuckConverter(int freq_kHz);
|
||||
|
||||
void set_voltage_limit(int voltage_mV);
|
||||
void set_current_limit(int current_mA);
|
||||
void set_max_voltage(int voltage_mV);
|
||||
void set_max_current(int current_mA);
|
||||
void set_min_current(int current_mA);
|
||||
time_t last_time_CV ();
|
||||
void last_time_CV_reset();
|
||||
|
||||
@@ -101,8 +102,11 @@ private:
|
||||
float _max_duty;
|
||||
int _pwm_delta;
|
||||
|
||||
bool _enabled;
|
||||
|
||||
int _max_voltage_mV;
|
||||
int _max_current_mA;
|
||||
int _min_current_mA;
|
||||
int _output_power_prev_mW;
|
||||
time_t _time_voltage_limit_reached;
|
||||
};
|
||||
|
||||
@@ -1,319 +0,0 @@
|
||||
/* mbed Library for EA DOG display
|
||||
*
|
||||
* This library is partly based on mbed DogLCD class by Igor Skochinsky and
|
||||
* the official Electronic Assembly library for Arduino
|
||||
*/
|
||||
|
||||
|
||||
#include "DogLCD.h"
|
||||
|
||||
// macro to make sure x falls into range from low to high (inclusive)
|
||||
#define CLAMP(x, low, high) { if ( (x) < (low) ) x = (low); if ( (x) > (high) ) x = (high); } while (0);
|
||||
|
||||
void DogLCD::_send_commands(const unsigned char* buf, size_t size)
|
||||
{
|
||||
// for commands, A0 is low
|
||||
#ifdef READJUST_SPI_FREQUENCY
|
||||
_spi.format(8,0);
|
||||
_spi.frequency(10000000);
|
||||
#endif
|
||||
_cs = 0;
|
||||
_a0 = 0;
|
||||
while ( size-- > 0 )
|
||||
_spi.write(*buf++);
|
||||
_cs = 1;
|
||||
}
|
||||
|
||||
void DogLCD::_send_data(const unsigned char* buf, size_t size)
|
||||
{
|
||||
// for data, A0 is high
|
||||
#ifdef READJUST_SPI_FREQUENCY
|
||||
_spi.format(8,0);
|
||||
_spi.frequency(10000000);
|
||||
#endif
|
||||
_cs = 0;
|
||||
_a0 = 1;
|
||||
while ( size-- > 0 )
|
||||
_spi.write(*buf++);
|
||||
_cs = 1;
|
||||
_a0 = 0;
|
||||
}
|
||||
|
||||
// set column and page number
|
||||
// void dog_1701::position(byte column, byte page)
|
||||
void DogLCD::_set_xy(int x, int y)
|
||||
{
|
||||
int column = x;
|
||||
int page = y;
|
||||
|
||||
if (_view == VIEW_TOP)
|
||||
column += 30;
|
||||
|
||||
unsigned char cmd[3];
|
||||
cmd[0] = 0x10 + (column>>4); //MSB adress column
|
||||
cmd[1] = 0x00 + (column&0x0F); //LSB adress column
|
||||
cmd[2] = 0xB0 + (page&0x0F); //adress page
|
||||
|
||||
/*
|
||||
//printf("_set_xy(%d,%d)\n", x, y);
|
||||
CLAMP(x, 0, LCDWIDTH-1);
|
||||
CLAMP(y, 0, LCDPAGES-1);
|
||||
unsigned char cmd[3];
|
||||
cmd[0] = 0xB0 | (y & 0xF);
|
||||
cmd[1] = (x & 0xF);
|
||||
cmd[2] = 0x10 | ((x >> 4) & 0xF);
|
||||
*/
|
||||
_send_commands(cmd, 3);
|
||||
}
|
||||
|
||||
// initialize and turn on the display
|
||||
void DogLCD::init()
|
||||
{
|
||||
const unsigned char init_seq[] = {
|
||||
0x40, //Display start line 0
|
||||
0xa1, //ADC reverse
|
||||
0xc0, //Normal COM0...COM63
|
||||
0xa6, //Display normal
|
||||
0xa2, //Set Bias 1/9 (Duty 1/65)
|
||||
0x2f, //Booster, Regulator and Follower On
|
||||
0xf8, //Set internal Booster to 4x
|
||||
0x00,
|
||||
0x27, //Contrast set
|
||||
0x81,
|
||||
0x09,
|
||||
0xac, //No indicator
|
||||
0x00,
|
||||
0xaf, //Display on
|
||||
};
|
||||
#ifndef READJUST_SPI_FREQUENCY
|
||||
_spi.format(8,0);
|
||||
_spi.frequency(10000000);
|
||||
#endif
|
||||
//printf("Reset=L\n");
|
||||
_reset = 0;
|
||||
_cs = 1;
|
||||
wait_ms(1);
|
||||
|
||||
//printf("Reset=H\n");
|
||||
_reset = 1;
|
||||
wait_ms(5);
|
||||
//printf("Sending init commands\n");
|
||||
_send_commands(init_seq, sizeof(init_seq));
|
||||
}
|
||||
|
||||
/*----------------------------
|
||||
Func: string
|
||||
Desc: shows string with selected font on position
|
||||
Vars: column (0..127/131), page(0..3/7), font adress in programm memory, stringarray
|
||||
------------------------------*/
|
||||
void DogLCD::string(int column, int page, const char *font_adress, const char *str)
|
||||
{
|
||||
unsigned int pos_array; //Postion of character data in memory array
|
||||
int x, y, column_cnt, width_max; //temporary column and page adress, couloumn_cnt tand width_max are used to stay inside display area
|
||||
int start_code, last_code, width, page_height, bytes_p_char; //font information, needed for calculation
|
||||
const char *string;
|
||||
|
||||
start_code = font_adress[2]; //get first defined character
|
||||
last_code = font_adress[3]; //get last defined character
|
||||
width = font_adress[4]; //width in pixel of one char
|
||||
page_height = font_adress[6]; //page count per char
|
||||
bytes_p_char = font_adress[7]; //bytes per char
|
||||
|
||||
if(page_height + page > 8) //stay inside display area
|
||||
page_height = 8 - page;
|
||||
|
||||
//The string is displayed character after character. If the font has more then one page,
|
||||
//the top page is printed first, then the next page and so on
|
||||
for(y = 0; y < page_height; y++)
|
||||
{
|
||||
_set_xy(column, page+y); //set startpositon and page
|
||||
column_cnt = column; //store column for display last column check
|
||||
string = str; //temporary pointer to the beginning of the string to print
|
||||
_cs = 0;
|
||||
_a0 = 1;
|
||||
while(*string != 0)
|
||||
{
|
||||
if((int)*string < start_code || (int)*string > last_code) //make sure data is valid
|
||||
string++;
|
||||
else
|
||||
{
|
||||
//calculate positon of ascii character in font array
|
||||
//bytes for header + (ascii - startcode) * bytes per char)
|
||||
pos_array = 8 + (unsigned int)(*string++ - start_code) * bytes_p_char;
|
||||
pos_array += y*width; //get the dot pattern for the part of the char to print
|
||||
|
||||
if(column_cnt + width > 102) //stay inside display area
|
||||
width_max = 102-column_cnt;
|
||||
else
|
||||
width_max = width;
|
||||
for(x=0; x < width_max; x++) //print the whole string
|
||||
{
|
||||
_spi.write(font_adress[pos_array+x]);
|
||||
//spi_out(pgm_read_byte(&font_adress[pos_array+x])); //double width font (bold)
|
||||
}
|
||||
column_cnt += width;
|
||||
}
|
||||
}
|
||||
_cs = 1;
|
||||
_a0 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------
|
||||
Func: view
|
||||
Desc: ssets the display viewing direction
|
||||
Vars: direction (top view 0xC8, bottom view (default) = 0xC0)
|
||||
------------------------------*/
|
||||
void DogLCD::view(unsigned int direction)
|
||||
{
|
||||
unsigned char cmd[2];
|
||||
|
||||
if(direction == VIEW_TOP)
|
||||
{
|
||||
cmd[0] = 0xA0;
|
||||
_view = VIEW_TOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd[0] = 0xA1;
|
||||
_view = VIEW_BOTTOM;
|
||||
}
|
||||
cmd[1] = direction;
|
||||
_send_commands(cmd, 2);
|
||||
|
||||
clear_screen(); //Clear screen, as old content is not usable (mirrored)
|
||||
}
|
||||
|
||||
void DogLCD::send_pic(const unsigned char* data)
|
||||
{
|
||||
//printf("Sending picture\n");
|
||||
for (int i=0; i<LCDPAGES; i++)
|
||||
{
|
||||
_set_xy(0, i);
|
||||
_send_data(data + i*LCDWIDTH, LCDWIDTH);
|
||||
}
|
||||
}
|
||||
|
||||
void DogLCD::clear_screen()
|
||||
{
|
||||
//printf("Clear screen\n");
|
||||
memset(_framebuffer, 0, sizeof(_framebuffer));
|
||||
if ( _updating == 0 )
|
||||
{
|
||||
send_pic(_framebuffer);
|
||||
}
|
||||
}
|
||||
|
||||
void DogLCD::all_on(bool on)
|
||||
{
|
||||
//printf("Sending all on %d\n", on);
|
||||
unsigned char cmd = 0xA4 | (on ? 1 : 0);
|
||||
_send_commands(&cmd, 1);
|
||||
}
|
||||
|
||||
void DogLCD::pixel(int x, int y, int colour)
|
||||
{
|
||||
CLAMP(x, 0, LCDWIDTH-1);
|
||||
CLAMP(y, 0, LCDHEIGHT-1);
|
||||
int page = y / 8;
|
||||
unsigned char mask = 1<<(y%8);
|
||||
unsigned char *byte = &_framebuffer[page*LCDWIDTH + x];
|
||||
if ( colour == 0 )
|
||||
*byte &= ~mask; // clear pixel
|
||||
else
|
||||
*byte |= mask; // set pixel
|
||||
if ( !_updating )
|
||||
{
|
||||
_set_xy(x, page);
|
||||
_send_data(byte, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void DogLCD::fill(int x, int y, int width, int height, int colour)
|
||||
{
|
||||
/*
|
||||
If we need to fill partial pages at the top:
|
||||
|
||||
......+---+---+.....
|
||||
^ | = | = | = : don't touch
|
||||
| | = | = | * : update
|
||||
y%8 | = | = |
|
||||
| | = | = |
|
||||
v | = | = |
|
||||
y----> | * | * |
|
||||
| * | * |
|
||||
| * | * |
|
||||
+---+---+
|
||||
*/
|
||||
//printf("fill(x=%d, y=%d, width=%d, height=%d, colour=%x)\n", x, y, width, height, colour);
|
||||
CLAMP(x, 0, LCDWIDTH-1);
|
||||
CLAMP(y, 0, LCDHEIGHT-1);
|
||||
CLAMP(width, 0, LCDWIDTH - x);
|
||||
CLAMP(height, 0, LCDHEIGHT - y);
|
||||
int page = y/8;
|
||||
int firstpage = page;
|
||||
int partpage = y%8;
|
||||
if ( partpage != 0 )
|
||||
{
|
||||
// we need to process partial bytes in the top page
|
||||
unsigned char mask = (1<<partpage) - 1; // this mask has 1s for bits we need to leave
|
||||
unsigned char *bytes = &_framebuffer[page*LCDWIDTH + x];
|
||||
for ( int i = 0; i < width; i++, bytes++ )
|
||||
{
|
||||
// clear "our" bits
|
||||
*bytes &= mask;
|
||||
if ( colour != 0 )
|
||||
*bytes |= ~mask; // set our bits
|
||||
}
|
||||
height -= partpage;
|
||||
page++;
|
||||
}
|
||||
while ( height >= 8 )
|
||||
{
|
||||
memset(&_framebuffer[page*LCDWIDTH + x], colour == 0 ? 0 : 0xFF, width);
|
||||
page++;
|
||||
height -= 8;
|
||||
}
|
||||
if ( height != 0 )
|
||||
{
|
||||
// we need to process partial bytes in the bottom page
|
||||
unsigned char mask = ~((1<<partpage) - 1); // this mask has 1s for bits we need to leave
|
||||
unsigned char *bytes = &_framebuffer[page*LCDWIDTH + x];
|
||||
for ( int i = 0; i < width; i++, bytes++ )
|
||||
{
|
||||
// clear "our" bits
|
||||
*bytes &= mask;
|
||||
if ( colour != 0 )
|
||||
*bytes |= ~mask; // set our bits
|
||||
}
|
||||
page++;
|
||||
}
|
||||
//printf("_updating=%d\n", _updating);
|
||||
if ( !_updating )
|
||||
{
|
||||
int laststpage = page;
|
||||
for ( page = firstpage; page < laststpage; page++)
|
||||
{
|
||||
//printf("setting x=%d, page=%d\n", x, page);
|
||||
_set_xy(x, page);
|
||||
//printf("sending %d bytes at offset %x\n", width, page*LCDWIDTH + x);
|
||||
_send_data(&_framebuffer[page*LCDWIDTH + x], width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DogLCD::beginupdate()
|
||||
{
|
||||
_updating++;
|
||||
//printf("beginupdate: %d\n", _updating);
|
||||
}
|
||||
|
||||
void DogLCD::endupdate()
|
||||
{
|
||||
_updating--;
|
||||
//printf("endupdate: %d\n", _updating);
|
||||
if ( _updating == 0 )
|
||||
{
|
||||
send_pic(_framebuffer);
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
/* mbed Library for EA DOG display
|
||||
*
|
||||
* This library is partly based on mbed DogLCD class by Igor Skochinsky and
|
||||
* the official Electronic Assembly library for Arduino
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __DOGLCD_H__
|
||||
#define __DOGLCD_H__
|
||||
|
||||
#include "mbed.h"
|
||||
|
||||
/***********
|
||||
* Module for Electronic Assembly's DOGL128-6 display module
|
||||
* Should be compatible with other modules using ST7565 controller
|
||||
***********/
|
||||
|
||||
#define LCDWIDTH 102
|
||||
#define LCDHEIGHT 64
|
||||
#define LCDPAGES (LCDHEIGHT+7)/8
|
||||
|
||||
|
||||
#define VIEW_BOTTOM 0xC0
|
||||
#define VIEW_TOP 0xC8
|
||||
|
||||
/*
|
||||
|
||||
Each page is 8 lines, one byte per column
|
||||
|
||||
Col0
|
||||
+---+--
|
||||
| 0 |
|
||||
Page 0 | 1 |
|
||||
| 2 |
|
||||
| 3 |
|
||||
| 4 |
|
||||
| 5 |
|
||||
| 6 |
|
||||
| 7 |
|
||||
+---+--
|
||||
*/
|
||||
|
||||
/*
|
||||
LCD interface class.
|
||||
Usage:
|
||||
DogLCD dog(spi, pin_power, pin_cs, pin_a0, pin_reset);
|
||||
where spi is an instance of SPI class
|
||||
*/
|
||||
|
||||
class DogLCD
|
||||
{
|
||||
public:
|
||||
|
||||
DogLCD(SPI& spi, PinName cs, PinName a0, PinName reset):
|
||||
_spi(spi), _cs(cs), _a0(a0), _reset(reset), _updating(0)
|
||||
{ }
|
||||
|
||||
void clear (void);
|
||||
void contrast (int contr);
|
||||
void view (unsigned int direction);
|
||||
void string (int column, int page, const char *font_adress, const char *str);
|
||||
void rectangle (int start_column, int start_page, int end_column, int end_page, int pattern);
|
||||
void picture (int column, int page, const int *pic_adress);
|
||||
|
||||
// initialize and turn on the display
|
||||
void init();
|
||||
// send a 128x64 picture for the whole screen
|
||||
void send_pic(const unsigned char* data);
|
||||
// clear screen
|
||||
void clear_screen();
|
||||
// turn all pixels on
|
||||
void all_on(bool on = true);
|
||||
|
||||
virtual int width() {return LCDWIDTH;};
|
||||
virtual int height() {return LCDHEIGHT;};
|
||||
virtual void pixel(int x, int y, int colour);
|
||||
virtual void fill(int x, int y, int width, int height, int colour);
|
||||
virtual void beginupdate();
|
||||
virtual void endupdate();
|
||||
|
||||
private:
|
||||
SPI& _spi;
|
||||
DigitalOut _cs, _a0, _reset;
|
||||
int _view;
|
||||
int _updating;
|
||||
|
||||
void _send_commands(const unsigned char* buf, size_t size);
|
||||
void _send_data(const unsigned char* buf, size_t size);
|
||||
void _set_xy(int x, int y);
|
||||
unsigned char _framebuffer[LCDWIDTH*LCDPAGES];
|
||||
|
||||
};
|
||||
|
||||
#endif //__DOGLCD_H__
|
||||
@@ -1,92 +0,0 @@
|
||||
/* File '16X32_numbers.FV' as include
|
||||
The font was generated with EA FontEditor. Please contact ELECTRONIC ASSEMBLY
|
||||
for more details (techik@lcd-module.de)
|
||||
|
||||
File based on official EA Arduino library.
|
||||
|
||||
the array starts with a 8 byte header:
|
||||
1st Byte: 'F' first 2 bytes are always FV
|
||||
2nd Byte: 'V' for FONT VERTICAL
|
||||
3rd Byte: First code to define
|
||||
4th Byte: Last code to define
|
||||
5th Byte: Width of character in dots
|
||||
6th Byte: Height of character in dots
|
||||
7th Byte: Height of character in bytes
|
||||
8th Byte: Bytes needed for each character (1..255)
|
||||
or 0 for big fonts calculate WidthInDots * HeightInBytes
|
||||
After that font data will follow */
|
||||
|
||||
#define FONT_16X32NUMS_LEN 1096
|
||||
|
||||
const char font_16x32nums[FONT_16X32NUMS_LEN] =
|
||||
{
|
||||
70, 86, 42, 58, 16, 32, 4, 64,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 6, 14, 28, 56,112,224,192,224,112, 56, 28, 14, 6, 0,
|
||||
0, 0, 48, 56, 28, 14, 7, 3, 1, 3, 7, 14, 28, 56, 48, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0,192,192,192,192,192,255,255,255,192,192,192,192,192, 0,
|
||||
0, 0, 1, 1, 1, 1, 1,127,127,127, 1, 1, 1, 1, 1, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,254,254,126, 30, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0,192,192,192,192,192,192,192,192,192,192,192,192,192, 0,
|
||||
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 28, 62, 62, 28, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,128,128, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0,192,192,192,192,195,199,199,195,192,192,192,192,192, 0,
|
||||
0, 0, 1, 1, 1, 1, 97,241,241, 97, 1, 1, 1, 1, 1, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0,224,248,252,252, 62, 30, 30, 30, 62,252,252,248,224, 0, 0,
|
||||
0,255,255,255,255, 0, 0,192,240, 60,255,255,255,255, 0, 0,
|
||||
0,255,255,255,255, 60, 15, 3, 0, 0,255,255,255,255, 0, 0,
|
||||
0, 7, 31, 63, 63,124,120,120,120,124, 63, 63, 31, 7, 0, 0,
|
||||
0, 0,128,192,224,240,248,252,254,254,254,252, 0, 0, 0, 0,
|
||||
0, 3, 7, 7, 7, 3, 1,255,255,255,255,255, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,255,255,255,255,255, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 63,127,127,127, 63, 0, 0, 0, 0,
|
||||
0,112,248,252,124, 62, 30, 30, 30, 62,252,252,248,224, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,128,192,240,255,255,255, 63, 0, 0,
|
||||
0,128,224,248,252,254,255, 63, 15, 7, 3, 1, 0, 0, 0, 0,
|
||||
0, 63,127,127,127,127,120,120,120,120,120,120,120, 48, 0, 0,
|
||||
0, 48,120,124, 60, 30, 30, 30, 62,252,252,248,240,192, 0, 0,
|
||||
0, 0, 0,128,192,192,192,192,224,255,255,255,127, 31, 0, 0,
|
||||
0, 0, 0, 1, 3, 3, 3, 3, 7,255,255,255,254,248, 0, 0,
|
||||
0, 12, 30, 62, 60,120,120,120,124, 63, 63, 31, 15, 3, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,192,240,252,254,254,254, 0, 0, 0,
|
||||
0, 0, 0,192,240,252,255, 63, 15,255,255,255,255, 0, 0, 0,
|
||||
0,252,255,255,255,195,192,192,192,255,255,255,255,192, 0, 0,
|
||||
0, 1, 1, 1, 1, 1, 1, 1, 1,127,127,127,127, 1, 0, 0,
|
||||
0,252,254,254,254, 30, 30, 30, 30, 30, 30, 30, 30, 12, 0, 0,
|
||||
0,255,255,255,255,192,224,224,224,224,192,128, 0, 0, 0, 0,
|
||||
0, 1, 3, 3, 3, 3, 1, 1, 1, 3,255,255,255,252, 0, 0,
|
||||
0, 12, 30, 62, 60,120,120,120,120, 60, 63, 31, 15, 3, 0, 0,
|
||||
0,192,240,248,252, 60, 30, 30, 30, 30, 60,124,120, 48, 0, 0,
|
||||
0,255,255,255,255,192,224,224,224,224,192,128, 0, 0, 0, 0,
|
||||
0,255,255,255,255, 3, 1, 1, 1, 3,255,255,255,252, 0, 0,
|
||||
0, 3, 15, 31, 63, 60,120,120,120, 60, 63, 31, 15, 3, 0, 0,
|
||||
0, 12, 30, 30, 30, 30, 30, 30, 30, 30,254,254,254,252, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,128,224,248,254,255, 63, 15, 3, 0, 0,
|
||||
0, 0, 0, 0,248,254,255,255, 15, 3, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 63,127,127, 63, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0,192,240,248,252, 60, 30, 30, 30, 60,252,248,240,192, 0, 0,
|
||||
0, 15, 63,127,255,240,224,224,224,240,255,127, 63, 15, 0, 0,
|
||||
0,248,254,255,255, 7, 3, 3, 3, 7,255,255,254,248, 0, 0,
|
||||
0, 3, 15, 31, 63, 60,120,120,120, 60, 63, 31, 15, 3, 0, 0,
|
||||
0,192,240,248,252, 60, 30, 30, 30, 60,252,248,240,192, 0, 0,
|
||||
0, 63,255,255,255,192,128,128,128,192,255,255,255,255, 0, 0,
|
||||
0, 0, 0, 1, 3, 3, 7, 7, 7, 3,255,255,255,255, 0, 0,
|
||||
0, 12, 30, 62, 60,120,120,120,120, 60, 63, 31, 15, 3, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,128,128,128,128, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 15, 15, 15, 15, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0,248,248,248,248, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
@@ -1,120 +0,0 @@
|
||||
/* File '6X8.FV' as include
|
||||
The font was generated with EA FontEditor. Please contact ELECTRONIC ASSEMBLY
|
||||
for more details (techik@lcd-module.de)
|
||||
|
||||
File based on official EA Arduino library.
|
||||
|
||||
the array starts with a 8 byte header:
|
||||
1st Byte: 'F' first 2 bytes are always FV
|
||||
2nd Byte: 'V' for FONT VERTICAL
|
||||
3rd Byte: First code to define
|
||||
4th Byte: Last code to define
|
||||
5th Byte: Width of character in dots
|
||||
6th Byte: Height of character in dots
|
||||
7th Byte: Height of character in bytes
|
||||
8th Byte: Bytes needed for each character (1..255)
|
||||
or 0 for big fonts calculate WidthInDots * HeightInBytes
|
||||
After that font data will follow */
|
||||
|
||||
#define FONT_6X8_LEN 584
|
||||
|
||||
const char font_6x8 [FONT_6X8_LEN] =
|
||||
{
|
||||
70, 86, 32,127, 6, 8, 1, 6,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
0, 0, 95, 0, 0, 0,
|
||||
0, 7, 0, 7, 0, 0,
|
||||
20,127, 20,127, 20, 0,
|
||||
36, 42,127, 42, 18, 0,
|
||||
35, 19, 8,100, 98, 0,
|
||||
54, 73, 86, 32, 80, 0,
|
||||
0, 8, 7, 3, 0, 0,
|
||||
0, 28, 34, 65, 0, 0,
|
||||
0, 65, 34, 28, 0, 0,
|
||||
42, 28,127, 28, 42, 0,
|
||||
8, 8, 62, 8, 8, 0,
|
||||
0,128,112, 48, 0, 0,
|
||||
8, 8, 8, 8, 8, 0,
|
||||
0, 0, 96, 96, 0, 0,
|
||||
32, 16, 8, 4, 2, 0,
|
||||
62, 81, 73, 69, 62, 0,
|
||||
0, 66,127, 64, 0, 0,
|
||||
66, 97, 81, 73, 70, 0,
|
||||
33, 65, 73, 77, 51, 0,
|
||||
24, 20, 18,127, 16, 0,
|
||||
39, 69, 69, 69, 57, 0,
|
||||
60, 74, 73, 73, 48, 0,
|
||||
65, 33, 17, 9, 7, 0,
|
||||
54, 73, 73, 73, 54, 0,
|
||||
6, 73, 73, 41, 30, 0,
|
||||
0, 0, 20, 0, 0, 0,
|
||||
0, 64, 52, 0, 0, 0,
|
||||
0, 8, 20, 34, 65, 0,
|
||||
20, 20, 20, 20, 20, 0,
|
||||
0, 65, 34, 20, 8, 0,
|
||||
2, 1, 81, 9, 6, 0,
|
||||
62, 65, 93, 89, 78, 0,
|
||||
124, 18, 17, 18,124, 0,
|
||||
127, 73, 73, 73, 54, 0,
|
||||
62, 65, 65, 65, 34, 0,
|
||||
127, 65, 65, 65, 62, 0,
|
||||
127, 73, 73, 73, 65, 0,
|
||||
127, 9, 9, 9, 1, 0,
|
||||
62, 65, 73, 73,122, 0,
|
||||
127, 8, 8, 8,127, 0,
|
||||
0, 65,127, 65, 0, 0,
|
||||
32, 64, 65, 63, 1, 0,
|
||||
127, 8, 20, 34, 65, 0,
|
||||
127, 64, 64, 64, 64, 0,
|
||||
127, 2, 28, 2,127, 0,
|
||||
127, 4, 8, 16,127, 0,
|
||||
62, 65, 65, 65, 62, 0,
|
||||
127, 9, 9, 9, 6, 0,
|
||||
62, 65, 81, 33, 94, 0,
|
||||
127, 9, 25, 41, 70, 0,
|
||||
38, 73, 73, 73, 50, 0,
|
||||
1, 1,127, 1, 1, 0,
|
||||
63, 64, 64, 64, 63, 0,
|
||||
31, 32, 64, 32, 31, 0,
|
||||
63, 64, 56, 64, 63, 0,
|
||||
99, 20, 8, 20, 99, 0,
|
||||
3, 4,120, 4, 3, 0,
|
||||
97, 81, 73, 69, 67, 0,
|
||||
0,127, 65, 65, 65, 0,
|
||||
2, 4, 8, 16, 32, 0,
|
||||
0, 65, 65, 65,127, 0,
|
||||
4, 2, 1, 2, 4, 0,
|
||||
64, 64, 64, 64, 64, 0,
|
||||
0, 3, 7, 8, 0, 0,
|
||||
32, 84, 84, 84,120, 0,
|
||||
127, 40, 68, 68, 56, 0,
|
||||
56, 68, 68, 68, 40, 0,
|
||||
56, 68, 68, 40,127, 0,
|
||||
56, 84, 84, 84, 24, 0,
|
||||
0, 8,126, 9, 2, 0,
|
||||
24,164,164,164,124, 0,
|
||||
127, 8, 4, 4,120, 0,
|
||||
0, 68,125, 64, 0, 0,
|
||||
32, 64, 64, 61, 0, 0,
|
||||
127, 16, 40, 68, 0, 0,
|
||||
0, 65,127, 64, 0, 0,
|
||||
124, 4,120, 4,120, 0,
|
||||
124, 8, 4, 4,120, 0,
|
||||
56, 68, 68, 68, 56, 0,
|
||||
252, 24, 36, 36, 24, 0,
|
||||
24, 36, 36, 24,252, 0,
|
||||
124, 8, 4, 4, 8, 0,
|
||||
72, 84, 84, 84, 36, 0,
|
||||
4, 4, 63, 68, 36, 0,
|
||||
60, 64, 64, 32,124, 0,
|
||||
28, 32, 64, 32, 28, 0,
|
||||
60, 64, 48, 64, 60, 0,
|
||||
68, 40, 16, 40, 68, 0,
|
||||
76,144,144,144,124, 0,
|
||||
68,100, 84, 76, 68, 0,
|
||||
0, 8, 54, 65, 0, 0,
|
||||
0, 0,119, 0, 0, 0,
|
||||
0, 65, 54, 8, 0, 0,
|
||||
2, 1, 2, 4, 2, 0,
|
||||
60, 38, 35, 38, 60, 0
|
||||
};
|
||||
@@ -1,120 +0,0 @@
|
||||
/* File '8X16neu.FV' as include
|
||||
The font was generated with EA FontEditor. Please contact ELECTRONIC ASSEMBLY
|
||||
for more details (techik@lcd-module.de)
|
||||
|
||||
File based on official EA Arduino library.
|
||||
|
||||
the array starts with a 8 byte header:
|
||||
1st Byte: 'F' first 2 bytes are always FV
|
||||
2nd Byte: 'V' for FONT VERTICAL
|
||||
3rd Byte: First code to define
|
||||
4th Byte: Last code to define
|
||||
5th Byte: Width of character in dots
|
||||
6th Byte: Height of character in dots
|
||||
7th Byte: Height of character in bytes
|
||||
8th Byte: Bytes needed for each character (1..255)
|
||||
or 0 for big fonts calculate WidthInDots * HeightInBytes
|
||||
After that font data will follow */
|
||||
|
||||
#define FONT_8X16_LEN 1544
|
||||
|
||||
const unsigned char font_8x16[FONT_8X16_LEN] =
|
||||
{
|
||||
70, 86, 32,127, 8, 16, 2, 16,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0,252,252, 0, 0, 0, 0, 0, 0, 51, 51, 0, 0, 0,
|
||||
0,252,252, 0, 0,252,252, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
48,252,252, 48, 48,252,252, 48, 3, 15, 15, 3, 3, 15, 15, 3,
|
||||
0,120,252,207,207,204,140, 0, 0, 12, 12, 60, 60, 15, 7, 0,
|
||||
0, 28, 28,192,240, 60, 12, 0, 0, 12, 15, 3, 0, 14, 14, 0,
|
||||
0,206,255,243, 63, 14, 0, 0, 31, 63, 48, 51, 31, 63, 51, 0,
|
||||
0, 0, 0,252,252, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0,240,248, 28, 4, 0, 0, 0, 0, 15, 31, 56, 32, 0,
|
||||
0, 4, 28,248,240, 0, 0, 0, 0, 32, 56, 31, 15, 0, 0, 0,
|
||||
192,204,252,240,240,252,204,192, 0, 12, 15, 3, 3, 15, 12, 0,
|
||||
0,192,192,248,248,192,192, 0, 0, 0, 0, 7, 7, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,192,124, 60, 0, 0, 0,
|
||||
0,192,192,192,192,192,192, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 60, 0, 0, 0,
|
||||
0, 0, 0,128,224,124, 28, 0, 0, 56, 62, 7, 1, 0, 0, 0,
|
||||
0,248,252, 12,140,252,248, 0, 0, 31, 63, 49, 48, 63, 31, 0,
|
||||
0, 0, 48,252,252, 0, 0, 0, 0, 48, 48, 63, 63, 48, 48, 0,
|
||||
0, 56, 60, 12,204,252, 56, 0, 0, 48, 60, 63, 51, 48, 48, 0,
|
||||
0, 12, 12,204,252, 60, 12, 0, 0, 28, 60, 48, 51, 63, 28, 0,
|
||||
0, 0,192,240,252,252, 0, 0, 0, 15, 15, 12, 63, 63, 12, 0,
|
||||
0,252,252,204,204,204,140, 0, 0, 24, 56, 48, 48, 63, 31, 0,
|
||||
0,240,248,156,140,140, 0, 0, 0, 31, 63, 49, 49, 63, 31, 0,
|
||||
0, 12, 12, 12,204,252, 60, 0, 0, 0, 60, 63, 3, 0, 0, 0,
|
||||
0, 56,252,204,204,252, 56, 0, 0, 31, 63, 48, 48, 63, 31, 0,
|
||||
0,120,252,204,204,252,248, 0, 0, 0, 48, 48, 56, 31, 15, 0,
|
||||
0, 0, 0,240,240, 0, 0, 0, 0, 0, 0, 60, 60, 0, 0, 0,
|
||||
0, 0, 0,240,240, 0, 0, 0, 0, 0,192,124, 60, 0, 0, 0,
|
||||
128,192,224,112, 56, 24, 8, 0, 0, 1, 3, 7, 14, 12, 8, 0,
|
||||
0, 48, 48, 48, 48, 48, 48, 0, 0, 3, 3, 3, 3, 3, 3, 0,
|
||||
8, 24, 56,112,224,192,128, 0, 8, 12, 14, 7, 3, 1, 0, 0,
|
||||
0, 56, 60, 12,204,252, 56, 0, 0, 0, 0, 55, 55, 0, 0, 0,
|
||||
240,248, 28,204, 76,152,240, 0, 15, 31, 56, 51, 50, 51, 25, 0,
|
||||
0,240,248, 28, 28,248,240, 0, 0, 63, 63, 3, 3, 63, 63, 0,
|
||||
0,252,252,204,204,252,120, 0, 0, 63, 63, 48, 48, 63, 31, 0,
|
||||
0,248,252, 12, 12, 60, 56, 0, 0, 31, 63, 48, 48, 60, 28, 0,
|
||||
0,252,252, 12, 28,248,240, 0, 0, 63, 63, 48, 56, 31, 15, 0,
|
||||
0,252,252,204,204,204, 12, 0, 0, 63, 63, 48, 48, 48, 48, 0,
|
||||
0,252,252,204,204,204, 12, 0, 0, 63, 63, 0, 0, 0, 0, 0,
|
||||
0,248,252, 12,204,204,204, 0, 0, 31, 63, 48, 48, 63, 31, 0,
|
||||
0,252,252,192,192,252,252, 0, 0, 63, 63, 0, 0, 63, 63, 0,
|
||||
0, 12, 12,252,252, 12, 12, 0, 0, 48, 48, 63, 63, 48, 48, 0,
|
||||
0, 0, 0, 0, 0,252,252, 0, 0, 28, 60, 48, 48, 63, 31, 0,
|
||||
252,252,192,240, 60, 12, 0, 0, 63, 63, 0, 3, 15, 60, 48, 0,
|
||||
0,252,252, 0, 0, 0, 0, 0, 0, 63, 63, 48, 48, 48, 48, 0,
|
||||
252,252,112,192,112,252,252, 0, 63, 63, 0, 1, 0, 63, 63, 0,
|
||||
0,252,252,224,128,252,252, 0, 0, 63, 63, 1, 7, 63, 63, 0,
|
||||
0,248,252, 12, 12,252,248, 0, 0, 31, 63, 48, 48, 63, 31, 0,
|
||||
0,252,252, 12, 12,252,248, 0, 0, 63, 63, 3, 3, 3, 1, 0,
|
||||
0,248,252, 12, 12,252,248, 0, 0, 31, 63, 48, 24, 55, 47, 0,
|
||||
252,252,140,140,252,248, 0, 0, 63, 63, 1, 3, 15, 60, 48, 0,
|
||||
0,120,252,204,140, 12, 12, 0, 0, 48, 48, 49, 51, 63, 30, 0,
|
||||
0, 12, 12,252,252, 12, 12, 0, 0, 0, 0, 63, 63, 0, 0, 0,
|
||||
0,252,252, 0, 0,252,252, 0, 0, 31, 63, 48, 48, 63, 31, 0,
|
||||
0,252,252, 0, 0,252,252, 0, 0, 3, 15, 60, 60, 15, 3, 0,
|
||||
252,252, 0,128, 0,252,252, 0, 63, 31, 14, 7, 14, 31, 63, 0,
|
||||
0, 28,124,224,224,124, 28, 0, 0, 56, 62, 7, 7, 62, 56, 0,
|
||||
0, 60,252,192,192,252, 60, 0, 0, 0, 0, 63, 63, 0, 0, 0,
|
||||
0, 12, 12,204,252, 60, 12, 0, 0, 60, 63, 51, 48, 48, 48, 0,
|
||||
0, 0, 0,252,252, 12, 12, 0, 0, 0, 0, 63, 63, 48, 48, 0,
|
||||
0, 28,124,224,128, 0, 0, 0, 0, 0, 0, 1, 7, 62, 56, 0,
|
||||
0, 12, 12,252,252, 0, 0, 0, 0, 48, 48, 63, 63, 0, 0, 0,
|
||||
128,224,120, 30,120,224,128, 0, 1, 1, 0, 0, 0, 1, 1, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 0,
|
||||
0, 7, 14, 28, 56,112, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 96, 96, 96,224,192, 0, 0, 30, 63, 51, 51, 63, 63, 0,
|
||||
0,252,252, 96, 96,224,192, 0, 0, 63, 63, 48, 48, 63, 31, 0,
|
||||
0,192,224, 96, 96, 96, 0, 0, 0, 31, 63, 48, 48, 48, 48, 0,
|
||||
0,192,224, 96, 96,252,252, 0, 0, 31, 63, 48, 48, 63, 63, 0,
|
||||
0,192,224, 96, 96,224,192, 0, 0, 31, 63, 50, 50, 51, 51, 0,
|
||||
0,192,192,248,252,204,204, 0, 0, 0, 0, 63, 63, 0, 0, 0,
|
||||
0,192,224, 96, 96,224,224, 0, 0,207,223,216,216,255,127, 0,
|
||||
0,252,252, 96, 96,224,192, 0, 0, 63, 63, 0, 0, 63, 63, 0,
|
||||
0, 0, 96,236,236, 0, 0, 0, 0, 0, 48, 63, 63, 48, 0, 0,
|
||||
0, 0, 0, 0,236,236, 0, 0, 0,192,192,192,255,127, 0, 0,
|
||||
252,252,128,192,224, 96, 0, 0, 63, 63, 3, 7, 30, 56, 48, 0,
|
||||
0, 0, 12,252,252, 0, 0, 0, 0, 0, 48, 63, 63, 48, 0, 0,
|
||||
192,224,224,192,224,224,192, 0, 63, 63, 0, 7, 0, 63, 63, 0,
|
||||
0,192,224, 96, 96,224,192, 0, 0, 63, 63, 0, 0, 63, 63, 0,
|
||||
0,192,224, 96, 96,224,192, 0, 0, 31, 63, 48, 48, 63, 31, 0,
|
||||
0,224,224, 96, 96,224,192, 0, 0,255,255, 48, 48, 63, 31, 0,
|
||||
0,192,224, 96, 96,224,224, 0, 0, 31, 63, 48, 48,255,255, 0,
|
||||
0,224,224, 96, 96,224,192, 0, 0, 63, 63, 0, 0, 0, 0, 0,
|
||||
0,192,224, 96, 96, 96, 96, 0, 0, 49, 51, 51, 54, 62, 28, 0,
|
||||
0, 96, 96,248,248, 96, 96, 0, 0, 0, 0, 31, 63, 48, 48, 0,
|
||||
0,224,224, 0, 0,224,224, 0, 0, 31, 63, 48, 48, 63, 63, 0,
|
||||
0,224,224, 0, 0,224,224, 0, 0, 3, 15, 60, 60, 15, 3, 0,
|
||||
224,224, 0,128, 0,224,224, 0, 63, 31, 14, 7, 14, 31, 63, 0,
|
||||
0, 96,224,128,128,224, 96, 0, 0, 48, 61, 15, 15, 61, 48, 0,
|
||||
0,224,224, 0, 0,224,224, 0, 0,207,223,216,216,255,127, 0,
|
||||
0, 96, 96, 96,224,224, 96, 0, 0, 48, 60, 63, 51, 48, 48, 0,
|
||||
128,128,192,252,126, 2, 2, 0, 1, 1, 3, 63,126, 64, 64, 0,
|
||||
0, 0, 0,254,254, 0, 0, 0, 0, 0, 0,127,127, 0, 0, 0,
|
||||
2, 2,126,252,192,128,128, 0, 64, 64,126, 63, 3, 1, 1, 0,
|
||||
192, 96,224,192,128,128,224, 0, 1, 0, 0, 1, 1, 1, 0, 0,
|
||||
0, 0,128,224,224,128, 0, 0, 24, 30, 19, 16, 16, 19, 30, 24
|
||||
};
|
||||
@@ -1,120 +0,0 @@
|
||||
/* File '8X8.FV' as include
|
||||
The font was generated with EA FontEditor. Please contact ELECTRONIC ASSEMBLY
|
||||
for more details (techik@lcd-module.de)
|
||||
|
||||
File based on official EA Arduino library.
|
||||
|
||||
the array starts with a 8 byte header:
|
||||
1st Byte: 'F' first 2 bytes are always FV
|
||||
2nd Byte: 'V' for FONT VERTICAL
|
||||
3rd Byte: First code to define
|
||||
4th Byte: Last code to define
|
||||
5th Byte: Width of character in dots
|
||||
6th Byte: Height of character in dots
|
||||
7th Byte: Height of character in bytes
|
||||
8th Byte: Bytes needed for each character (1..255)
|
||||
or 0 for big fonts calculate WidthInDots * HeightInBytes
|
||||
After that font data will follow */
|
||||
|
||||
#define FONT_8X8_LEN 776
|
||||
|
||||
const unsigned char font_8x8[FONT_8X8_LEN] =
|
||||
{
|
||||
70, 86, 32,127, 8, 8, 1, 8,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 95, 95, 0, 0, 0,
|
||||
0, 7, 7, 0, 0, 7, 7, 0,
|
||||
36,126,126, 36,126,126, 36, 0,
|
||||
0, 36, 46,107,107, 58, 18, 0,
|
||||
0,102, 54, 24, 12,102, 98, 0,
|
||||
48,122, 79, 93, 55,114, 80, 0,
|
||||
0, 0, 0, 7, 7, 0, 0, 0,
|
||||
0, 0, 0, 62,127, 99, 65, 0,
|
||||
0, 65, 99,127, 62, 0, 0, 0,
|
||||
8, 42, 62, 28, 28, 62, 42, 8,
|
||||
0, 8, 8, 62, 62, 8, 8, 0,
|
||||
0,128,224, 96, 0, 0, 0, 0,
|
||||
0, 8, 8, 8, 8, 8, 8, 0,
|
||||
0, 0, 0, 96, 96, 0, 0, 0,
|
||||
0, 96, 48, 24, 12, 6, 3, 0,
|
||||
0, 62,127, 73, 69,127, 62, 0,
|
||||
0, 64, 66,127,127, 64, 64, 0,
|
||||
0, 66, 99,113, 89, 79, 70, 0,
|
||||
0, 33, 97, 69, 79,123, 49, 0,
|
||||
0, 24, 28, 22,127,127, 16, 0,
|
||||
0, 39,103, 69, 69,125, 57, 0,
|
||||
0, 62,127, 73, 73,121, 48, 0,
|
||||
0, 1,113,121, 13, 7, 3, 0,
|
||||
0, 54,127, 73, 73,127, 54, 0,
|
||||
0, 6, 79, 73,105, 63, 30, 0,
|
||||
0, 0, 0, 54, 54, 0, 0, 0,
|
||||
0, 0, 64,118, 54, 0, 0, 0,
|
||||
0, 0, 8, 28, 54, 99, 65, 0,
|
||||
0, 36, 36, 36, 36, 36, 36, 0,
|
||||
0, 65, 99, 54, 28, 8, 0, 0,
|
||||
0, 2, 3, 81, 89, 15, 6, 0,
|
||||
0, 62,127, 65, 93, 87, 94, 0,
|
||||
0,124,126, 19, 19,126,124, 0,
|
||||
0,127,127, 73, 73,127, 54, 0,
|
||||
0, 62,127, 65, 65, 99, 34, 0,
|
||||
0,127,127, 65, 99, 62, 28, 0,
|
||||
0,127,127, 73, 73, 73, 65, 0,
|
||||
0,127,127, 9, 9, 9, 1, 0,
|
||||
0, 62,127, 65, 73,121,121, 0,
|
||||
0,127,127, 8, 8,127,127, 0,
|
||||
0, 0, 65,127,127, 65, 0, 0,
|
||||
0, 32, 96, 64, 64,127, 63, 0,
|
||||
0,127,127, 28, 54, 99, 65, 0,
|
||||
0,127,127, 64, 64, 64, 64, 0,
|
||||
127,127, 6, 12, 6,127,127, 0,
|
||||
0,127,127, 14, 28,127,127, 0,
|
||||
0, 62,127, 65, 65,127, 62, 0,
|
||||
0,127,127, 9, 9, 15, 6, 0,
|
||||
0, 62,127, 81, 33,127, 94, 0,
|
||||
0,127,127, 9, 25,127,102, 0,
|
||||
0, 38,111, 73, 73,123, 50, 0,
|
||||
0, 1, 1,127,127, 1, 1, 0,
|
||||
0, 63,127, 64, 64,127,127, 0,
|
||||
0, 31, 63, 96, 96, 63, 31, 0,
|
||||
127,127, 48, 24, 48,127,127, 0,
|
||||
0, 99,119, 28, 28,119, 99, 0,
|
||||
0, 7, 15,120,120, 15, 7, 0,
|
||||
0, 97,113, 89, 77, 71, 67, 0,
|
||||
0, 0, 0,127,127, 65, 65, 0,
|
||||
0, 3, 6, 12, 24, 48, 96, 0,
|
||||
0, 65, 65,127,127, 0, 0, 0,
|
||||
8, 12, 6, 3, 6, 12, 8, 0,
|
||||
64, 64, 64, 64, 64, 64, 64, 0,
|
||||
2, 6, 12, 8, 0, 0, 0, 0,
|
||||
0, 32,116, 84, 84,124,120, 0,
|
||||
0,127,127, 68, 68,124, 56, 0,
|
||||
0, 56,124, 68, 68, 68, 0, 0,
|
||||
0, 56,124, 68, 68,127,127, 0,
|
||||
0, 56,124, 84, 84, 92, 24, 0,
|
||||
0, 4,126,127, 5, 5, 0, 0,
|
||||
0,152,188,164,164,252,124, 0,
|
||||
0,127,127, 4, 4,124,120, 0,
|
||||
0, 0, 68,125,125, 64, 0, 0,
|
||||
0,128,128,253,125, 0, 0, 0,
|
||||
0,127,127, 16, 56,108, 68, 0,
|
||||
0, 0, 65,127,127, 64, 0, 0,
|
||||
124,124, 12, 24, 12,124,120, 0,
|
||||
0,124,124, 4, 4,124,120, 0,
|
||||
0, 56,124, 68, 68,124, 56, 0,
|
||||
0,252,252, 68, 68,124, 56, 0,
|
||||
0, 56,124, 68, 68,252,252, 0,
|
||||
0,124,124, 4, 4, 12, 8, 0,
|
||||
0, 72, 92, 84, 84,116, 36, 0,
|
||||
0, 4, 4, 62,126, 68, 68, 0,
|
||||
0, 60,124, 64, 64,124,124, 0,
|
||||
0, 28, 60, 96, 96, 60, 28, 0,
|
||||
28,124, 96, 48, 96,124, 28, 0,
|
||||
0, 68,108, 56, 56,108, 68, 0,
|
||||
0,156,188,160,160,252,124, 0,
|
||||
0, 68,100,116, 92, 76, 68, 0,
|
||||
0, 0, 8, 62,119, 65, 65, 0,
|
||||
0, 0, 0,255,255, 0, 0, 0,
|
||||
0, 65, 65,119, 62, 8, 0, 0,
|
||||
12, 6, 6, 12, 24, 24, 12, 0,
|
||||
0, 96,120, 94, 70, 88, 96, 0
|
||||
};
|
||||
@@ -1,169 +0,0 @@
|
||||
/* mbed library for half bridge driver PWM generation
|
||||
* Copyright (c) 2016 Martin Jäger (www.libre.solar)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "HalfBridge.h"
|
||||
|
||||
HalfBridge::HalfBridge(PinName pin_HS, PinName pin_LS)
|
||||
{
|
||||
// Enable peripheral clock of GPIOA and GPIOB
|
||||
RCC->AHBENR |= RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN;
|
||||
|
||||
// Enable TIM1 clock
|
||||
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN;
|
||||
|
||||
// Select alternate function mode on PA8 und PB13
|
||||
GPIOA->MODER = (GPIOA->MODER & ~(GPIO_MODER_MODER8)) | GPIO_MODER_MODER8_1;
|
||||
GPIOB->MODER = (GPIOB->MODER & ~(GPIO_MODER_MODER13)) | GPIO_MODER_MODER13_1;
|
||||
|
||||
// Select AF2 on PA8 (TIM1_CH1)
|
||||
GPIOA->AFR[1] |= 0x2 << ((8 - 8)*4); // AFR[1] for pins 8-15
|
||||
|
||||
// Select AF2 on PB13 (TIM1_CH1N)
|
||||
GPIOB->AFR[1] |= 0x2 << ((13 - 8)*4); // AFR[1] for pins 8-15
|
||||
|
||||
// No prescaler --> timer frequency = 48 MHz
|
||||
TIM1->PSC = 0;
|
||||
|
||||
// Capture/Compare Mode Register 1
|
||||
// OC1M = 110: Select PWM mode 1 on OC1
|
||||
// OC1PE = 1: Enable preload register on OC1 (reset value)
|
||||
TIM1->CCMR1 |= TIM_CCMR1_OC1M_2 | TIM_CCMR1_OC1M_1 | TIM_CCMR1_OC1PE;
|
||||
|
||||
// Capture/Compare Enable Register
|
||||
// CC1E = 1: Enable the output on OC1
|
||||
// CC1P = 0: Active high polarity on OC1 (default)
|
||||
// CC1NE = 1: Enable the output on OC1N
|
||||
// CC1NP = 0: Active high polarity on OC1N (default)
|
||||
TIM1->CCER |= TIM_CCER_CC1E | TIM_CCER_CC1NE;// | TIM_CCER_CC1NP;
|
||||
|
||||
// Control Register 1
|
||||
// TIM_CR1_CMS = 01: Select center-aligned mode 1
|
||||
// TIM_CR1_CEN = 1: Counter enable
|
||||
TIM1->CR1 |= TIM_CR1_CMS_0 | TIM_CR1_CEN;
|
||||
|
||||
// Control Register 2
|
||||
// OIS1 = OIS1N = 0: Output Idle State is set to off
|
||||
//TIM1->CR2 |= ;
|
||||
|
||||
// Force update generation (UG = 1)
|
||||
TIM1->EGR |= TIM_EGR_UG;
|
||||
|
||||
// initialize frequency to set _pwm_resolution
|
||||
frequency_kHz(1);
|
||||
|
||||
set_duty_cycle(0.5); // safer than 0 for DC/DC
|
||||
}
|
||||
|
||||
void HalfBridge::frequency_kHz(int freq) {
|
||||
|
||||
_pwm_resolution = SystemCoreClock / (freq * 1000);
|
||||
|
||||
// Auto Reload Register
|
||||
// center-aligned mode --> divide resolution by 2
|
||||
TIM1->ARR = _pwm_resolution / 2;
|
||||
}
|
||||
|
||||
|
||||
void HalfBridge::set_duty_cycle(float duty) {
|
||||
|
||||
float duty_target;
|
||||
// protection against wrong settings which could destroy the hardware
|
||||
if (duty < _min_duty) {
|
||||
duty_target = _min_duty;
|
||||
}
|
||||
else if (duty > _max_duty) {
|
||||
duty_target = _max_duty;
|
||||
}
|
||||
else {
|
||||
duty_target = duty;
|
||||
}
|
||||
|
||||
TIM1->CCR1 = _pwm_resolution / 2 * duty_target;
|
||||
}
|
||||
|
||||
void HalfBridge::duty_cycle_step(int delta)
|
||||
{
|
||||
float duty_target;
|
||||
duty_target = (float)(TIM1->CCR1 + delta) / (_pwm_resolution / 2);
|
||||
|
||||
// protection against wrong settings which could destroy the hardware
|
||||
if (duty_target < _min_duty) {
|
||||
set_duty_cycle(_min_duty);
|
||||
}
|
||||
else if (duty_target > _max_duty) {
|
||||
set_duty_cycle(_max_duty);
|
||||
}
|
||||
else {
|
||||
TIM1->CCR1 = TIM1->CCR1 + delta;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
float HalfBridge::get_duty_cycle() {
|
||||
return (float)(TIM1->CCR1) / (_pwm_resolution / 2);;
|
||||
}
|
||||
|
||||
|
||||
void HalfBridge::deadtime_ns(int deadtime) {
|
||||
|
||||
uint8_t deadtime_clocks = (SystemCoreClock / 1000 / 1000) * deadtime / 1000;
|
||||
|
||||
// Break and Dead-Time Register
|
||||
// MOE = 1: Main output enable
|
||||
// OSSR = 0: Off-state selection for Run mode -> OC/OCN = 0
|
||||
// OSSI = 0: Off-state selection for Idle mode -> OC/OCN = 0
|
||||
TIM1->BDTR |= (deadtime_clocks & (uint32_t)0x7F); // ensure that only the last 7 bits are changed
|
||||
}
|
||||
|
||||
|
||||
void HalfBridge::start() {
|
||||
|
||||
// Break and Dead-Time Register
|
||||
// MOE = 1: Main output enable
|
||||
TIM1->BDTR |= TIM_BDTR_MOE;
|
||||
}
|
||||
|
||||
|
||||
void HalfBridge::stop() {
|
||||
|
||||
// Break and Dead-Time Register
|
||||
// MOE = 1: Main output enable
|
||||
TIM1->BDTR &= ~(TIM_BDTR_MOE);
|
||||
}
|
||||
|
||||
|
||||
void HalfBridge::lock_settings() {
|
||||
|
||||
// TODO: does not work properly, yet...
|
||||
|
||||
// Break and Dead-Time Register
|
||||
TIM1->BDTR |= TIM_BDTR_LOCK_1 | TIM_BDTR_LOCK_0;
|
||||
}
|
||||
|
||||
void HalfBridge::duty_cycle_limits(float min_duty, float max_duty) {
|
||||
|
||||
_min_duty = min_duty;
|
||||
_max_duty = max_duty;
|
||||
|
||||
// adjust set value to new limits
|
||||
if (get_duty_cycle() < _min_duty) {
|
||||
set_duty_cycle(_min_duty);
|
||||
}
|
||||
else if (get_duty_cycle() > _max_duty) {
|
||||
set_duty_cycle(_max_duty);
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
/* mbed library for half bridge driver PWM generation
|
||||
* Copyright (c) 2016 Martin Jäger (www.libre.solar)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "mbed.h"
|
||||
|
||||
class HalfBridge
|
||||
{
|
||||
public:
|
||||
|
||||
/** Create a half bridge class for the specified pins
|
||||
*
|
||||
* @param pin_HS PinName of the high-side output
|
||||
* @param pin_LS PinName of the low-side output
|
||||
*/
|
||||
HalfBridge(PinName pin_HS, PinName pin_LS);
|
||||
|
||||
/** Set the PWM frequency in kHz
|
||||
*
|
||||
* @param freq Frequency in kHz
|
||||
*/
|
||||
void frequency_kHz(int freq);
|
||||
|
||||
/** Set the deadtime between switching the two FETs on/off
|
||||
*
|
||||
* @param deadtime Deadtime in ns
|
||||
*/
|
||||
void deadtime_ns(int deadtime);
|
||||
|
||||
/** Lock the settings of PWM generation to prevent accidental changes
|
||||
* (does not work properly, yet! --> TODO)
|
||||
*/
|
||||
void lock_settings(void);
|
||||
|
||||
/** Start the PWM generation
|
||||
*/
|
||||
void start();
|
||||
|
||||
/** Stop the PWM generation
|
||||
*/
|
||||
void stop();
|
||||
|
||||
/** Set the duty cycle of the PWM signal between 0.0 and 1.0
|
||||
*
|
||||
* @param duty Duty cycle between 0.0 and 1.0
|
||||
*/
|
||||
void set_duty_cycle(float duty);
|
||||
|
||||
/** Adjust the duty cycle with minimum step size
|
||||
*
|
||||
* @param delta Number of steps (positive or negative)
|
||||
*/
|
||||
void duty_cycle_step(int delta);
|
||||
|
||||
/** Read the currently set duty cycle
|
||||
*
|
||||
* @returns
|
||||
* Duty cycle between 0.0 and 1.0
|
||||
*/
|
||||
float get_duty_cycle();
|
||||
|
||||
/** Set limits for the duty cycle to prevent hardware damages
|
||||
*
|
||||
* @param min_duty Minimum duty cycle (e.g. 0.5 for limiting input voltage)
|
||||
* @param max_duty Maximum duty cycle (e.g. 0.97 for charge pump)
|
||||
*/
|
||||
void duty_cycle_limits(float min_duty, float max_duty);
|
||||
|
||||
private:
|
||||
int _pwm_resolution;
|
||||
float _min_duty;
|
||||
float _max_duty;
|
||||
|
||||
};
|
||||
-324
@@ -1,324 +0,0 @@
|
||||
/**
|
||||
* @author Aaron Berk
|
||||
*
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright (c) 2010 ARM Limited
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @section DESCRIPTION
|
||||
*
|
||||
* A PID controller is a widely used feedback controller commonly found in
|
||||
* industry.
|
||||
*
|
||||
* This library is a port of Brett Beauregard's Arduino PID library:
|
||||
*
|
||||
* http://www.arduino.cc/playground/Code/PIDLibrary
|
||||
*
|
||||
* The wikipedia article on PID controllers is a good place to start on
|
||||
* understanding how they work:
|
||||
*
|
||||
* http://en.wikipedia.org/wiki/PID_controller
|
||||
*
|
||||
* For a clear and elegant explanation of how to implement and tune a
|
||||
* controller, the controlguru website by Douglas J. Cooper (who also happened
|
||||
* to be Brett's controls professor) is an excellent reference:
|
||||
*
|
||||
* http://www.controlguru.com/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Includes
|
||||
*/
|
||||
#include "PID.h"
|
||||
|
||||
PID::PID(float Kc, float tauI, float tauD, float interval) {
|
||||
|
||||
usingFeedForward = false;
|
||||
inAuto = false;
|
||||
|
||||
//Default the limits to the full range of I/O: 3.3V
|
||||
//Make sure to set these to more appropriate limits for
|
||||
//your application.
|
||||
setInputLimits(0.0, 3.3);
|
||||
setOutputLimits(0.0, 3.3);
|
||||
|
||||
tSample_ = interval;
|
||||
|
||||
setTunings(Kc, tauI, tauD);
|
||||
|
||||
setPoint_ = 0.0;
|
||||
processVariable_ = 0.0;
|
||||
prevProcessVariable_ = 0.0;
|
||||
controllerOutput_ = 0.0;
|
||||
prevControllerOutput_ = 0.0;
|
||||
|
||||
accError_ = 0.0;
|
||||
bias_ = 0.0;
|
||||
|
||||
realOutput_ = 0.0;
|
||||
|
||||
}
|
||||
|
||||
void PID::setInputLimits(float inMin, float inMax) {
|
||||
|
||||
//Make sure we haven't been given impossible values.
|
||||
if (inMin >= inMax) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Rescale the working variables to reflect the changes.
|
||||
prevProcessVariable_ *= (inMax - inMin) / inSpan_;
|
||||
accError_ *= (inMax - inMin) / inSpan_;
|
||||
|
||||
//Make sure the working variables are within the new limits.
|
||||
if (prevProcessVariable_ > 1) {
|
||||
prevProcessVariable_ = 1;
|
||||
} else if (prevProcessVariable_ < 0) {
|
||||
prevProcessVariable_ = 0;
|
||||
}
|
||||
|
||||
inMin_ = inMin;
|
||||
inMax_ = inMax;
|
||||
inSpan_ = inMax - inMin;
|
||||
|
||||
}
|
||||
|
||||
void PID::setOutputLimits(float outMin, float outMax) {
|
||||
|
||||
//Make sure we haven't been given impossible values.
|
||||
if (outMin >= outMax) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Rescale the working variables to reflect the changes.
|
||||
prevControllerOutput_ *= (outMax - outMin) / outSpan_;
|
||||
|
||||
//Make sure the working variables are within the new limits.
|
||||
if (prevControllerOutput_ > 1) {
|
||||
prevControllerOutput_ = 1;
|
||||
} else if (prevControllerOutput_ < 0) {
|
||||
prevControllerOutput_ = 0;
|
||||
}
|
||||
|
||||
outMin_ = outMin;
|
||||
outMax_ = outMax;
|
||||
outSpan_ = outMax - outMin;
|
||||
|
||||
}
|
||||
|
||||
void PID::setTunings(float Kc, float tauI, float tauD) {
|
||||
|
||||
//Verify that the tunings make sense.
|
||||
if (Kc == 0.0 || tauI < 0.0 || tauD < 0.0) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Store raw values to hand back to user on request.
|
||||
pParam_ = Kc;
|
||||
iParam_ = tauI;
|
||||
dParam_ = tauD;
|
||||
|
||||
float tempTauR;
|
||||
|
||||
if (tauI == 0.0) {
|
||||
tempTauR = 0.0;
|
||||
} else {
|
||||
tempTauR = (1.0 / tauI) * tSample_;
|
||||
}
|
||||
|
||||
//For "bumpless transfer" we need to rescale the accumulated error.
|
||||
if (inAuto) {
|
||||
if (tempTauR == 0.0) {
|
||||
accError_ = 0.0;
|
||||
} else {
|
||||
accError_ *= (Kc_ * tauR_) / (Kc * tempTauR);
|
||||
}
|
||||
}
|
||||
|
||||
Kc_ = Kc;
|
||||
tauR_ = tempTauR;
|
||||
tauD_ = tauD / tSample_;
|
||||
|
||||
}
|
||||
|
||||
void PID::reset(void) {
|
||||
|
||||
float scaledBias = 0.0;
|
||||
|
||||
if (usingFeedForward) {
|
||||
scaledBias = (bias_ - outMin_) / outSpan_;
|
||||
} else {
|
||||
scaledBias = (realOutput_ - outMin_) / outSpan_;
|
||||
}
|
||||
|
||||
prevControllerOutput_ = scaledBias;
|
||||
prevProcessVariable_ = (processVariable_ - inMin_) / inSpan_;
|
||||
|
||||
//Clear any error in the integral.
|
||||
accError_ = 0;
|
||||
|
||||
}
|
||||
|
||||
void PID::setMode(int mode) {
|
||||
|
||||
//We were in manual, and we just got set to auto.
|
||||
//Reset the controller internals.
|
||||
if (mode != 0 && !inAuto) {
|
||||
reset();
|
||||
}
|
||||
|
||||
inAuto = (mode != 0);
|
||||
|
||||
}
|
||||
|
||||
void PID::setInterval(float interval) {
|
||||
|
||||
if (interval > 0) {
|
||||
//Convert the time-based tunings to reflect this change.
|
||||
tauR_ *= (interval / tSample_);
|
||||
accError_ *= (tSample_ / interval);
|
||||
tauD_ *= (interval / tSample_);
|
||||
tSample_ = interval;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PID::setSetPoint(float sp) {
|
||||
|
||||
setPoint_ = sp;
|
||||
|
||||
}
|
||||
|
||||
void PID::setProcessValue(float pv) {
|
||||
|
||||
processVariable_ = pv;
|
||||
|
||||
}
|
||||
|
||||
void PID::setBias(float bias){
|
||||
|
||||
bias_ = bias;
|
||||
usingFeedForward = 1;
|
||||
|
||||
}
|
||||
|
||||
float PID::compute() {
|
||||
|
||||
//Pull in the input and setpoint, and scale them into percent span.
|
||||
float scaledPV = (processVariable_ - inMin_) / inSpan_;
|
||||
|
||||
if (scaledPV > 1.0) {
|
||||
scaledPV = 1.0;
|
||||
} else if (scaledPV < 0.0) {
|
||||
scaledPV = 0.0;
|
||||
}
|
||||
|
||||
float scaledSP = (setPoint_ - inMin_) / inSpan_;
|
||||
if (scaledSP > 1.0) {
|
||||
scaledSP = 1;
|
||||
} else if (scaledSP < 0.0) {
|
||||
scaledSP = 0;
|
||||
}
|
||||
|
||||
float error = scaledSP - scaledPV;
|
||||
|
||||
//Check and see if the output is pegged at a limit and only
|
||||
//integrate if it is not. This is to prevent reset-windup.
|
||||
if (!(prevControllerOutput_ >= 1 && error > 0) && !(prevControllerOutput_ <= 0 && error < 0)) {
|
||||
accError_ += error;
|
||||
}
|
||||
|
||||
//Compute the current slope of the input signal.
|
||||
float dMeas = (scaledPV - prevProcessVariable_) / tSample_;
|
||||
|
||||
float scaledBias = 0.0;
|
||||
|
||||
if (usingFeedForward) {
|
||||
scaledBias = (bias_ - outMin_) / outSpan_;
|
||||
}
|
||||
|
||||
//Perform the PID calculation.
|
||||
controllerOutput_ = scaledBias + Kc_ * (error + (tauR_ * accError_) - (tauD_ * dMeas));
|
||||
|
||||
//Make sure the computed output is within output constraints.
|
||||
if (controllerOutput_ < 0.0) {
|
||||
controllerOutput_ = 0.0;
|
||||
} else if (controllerOutput_ > 1.0) {
|
||||
controllerOutput_ = 1.0;
|
||||
}
|
||||
|
||||
//Remember this output for the windup check next time.
|
||||
prevControllerOutput_ = controllerOutput_;
|
||||
//Remember the input for the derivative calculation next time.
|
||||
prevProcessVariable_ = scaledPV;
|
||||
|
||||
//Scale the output from percent span back out to a real world number.
|
||||
return ((controllerOutput_ * outSpan_) + outMin_);
|
||||
|
||||
}
|
||||
|
||||
float PID::getInMin() {
|
||||
|
||||
return inMin_;
|
||||
|
||||
}
|
||||
|
||||
float PID::getInMax() {
|
||||
|
||||
return inMax_;
|
||||
|
||||
}
|
||||
|
||||
float PID::getOutMin() {
|
||||
|
||||
return outMin_;
|
||||
|
||||
}
|
||||
|
||||
float PID::getOutMax() {
|
||||
|
||||
return outMax_;
|
||||
|
||||
}
|
||||
|
||||
float PID::getInterval() {
|
||||
|
||||
return tSample_;
|
||||
|
||||
}
|
||||
|
||||
float PID::getPParam() {
|
||||
|
||||
return pParam_;
|
||||
|
||||
}
|
||||
|
||||
float PID::getIParam() {
|
||||
|
||||
return iParam_;
|
||||
|
||||
}
|
||||
|
||||
float PID::getDParam() {
|
||||
|
||||
return dParam_;
|
||||
|
||||
}
|
||||
-213
@@ -1,213 +0,0 @@
|
||||
/**
|
||||
* @author Aaron Berk
|
||||
*
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright (c) 2010 ARM Limited
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @section DESCRIPTION
|
||||
*
|
||||
* A PID controller is a widely used feedback controller commonly found in
|
||||
* industry.
|
||||
*
|
||||
* This library is a port of Brett Beauregard's Arduino PID library:
|
||||
*
|
||||
* http://www.arduino.cc/playground/Code/PIDLibrary
|
||||
*
|
||||
* The wikipedia article on PID controllers is a good place to start on
|
||||
* understanding how they work:
|
||||
*
|
||||
* http://en.wikipedia.org/wiki/PID_controller
|
||||
*
|
||||
* For a clear and elegant explanation of how to implement and tune a
|
||||
* controller, the controlguru website by Douglas J. Cooper (who also happened
|
||||
* to be Brett's controls professor) is an excellent reference:
|
||||
*
|
||||
* http://www.controlguru.com/
|
||||
*/
|
||||
|
||||
#ifndef PID_H
|
||||
#define PID_H
|
||||
|
||||
/**
|
||||
* Includes
|
||||
*/
|
||||
#include "mbed.h"
|
||||
|
||||
/**
|
||||
* Defines
|
||||
*/
|
||||
#define MANUAL_MODE 0
|
||||
#define AUTO_MODE 1
|
||||
|
||||
/**
|
||||
* Proportional-integral-derivative controller.
|
||||
*/
|
||||
class PID {
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Sets default limits [0-3.3V], calculates tuning parameters, and sets
|
||||
* manual mode with no bias.
|
||||
*
|
||||
* @param Kc - Tuning parameter
|
||||
* @param tauI - Tuning parameter
|
||||
* @param tauD - Tuning parameter
|
||||
* @param interval PID calculation performed every interval seconds.
|
||||
*/
|
||||
PID(float Kc, float tauI, float tauD, float interval);
|
||||
|
||||
/**
|
||||
* Scale from inputs to 0-100%.
|
||||
*
|
||||
* @param InMin The real world value corresponding to 0%.
|
||||
* @param InMax The real world value corresponding to 100%.
|
||||
*/
|
||||
void setInputLimits(float inMin , float inMax);
|
||||
|
||||
/**
|
||||
* Scale from outputs to 0-100%.
|
||||
*
|
||||
* @param outMin The real world value corresponding to 0%.
|
||||
* @param outMax The real world value corresponding to 100%.
|
||||
*/
|
||||
void setOutputLimits(float outMin, float outMax);
|
||||
|
||||
/**
|
||||
* Calculate PID constants.
|
||||
*
|
||||
* Allows parameters to be changed on the fly without ruining calculations.
|
||||
*
|
||||
* @param Kc - Tuning parameter
|
||||
* @param tauI - Tuning parameter
|
||||
* @param tauD - Tuning parameter
|
||||
*/
|
||||
void setTunings(float Kc, float tauI, float tauD);
|
||||
|
||||
/**
|
||||
* Reinitializes controller internals. Automatically
|
||||
* called on a manual to auto transition.
|
||||
*/
|
||||
void reset(void);
|
||||
|
||||
/**
|
||||
* Set PID to manual or auto mode.
|
||||
*
|
||||
* @param mode 0 -> Manual
|
||||
* Non-zero -> Auto
|
||||
*/
|
||||
void setMode(int mode);
|
||||
|
||||
/**
|
||||
* Set how fast the PID loop is run.
|
||||
*
|
||||
* @param interval PID calculation peformed every interval seconds.
|
||||
*/
|
||||
void setInterval(float interval);
|
||||
|
||||
/**
|
||||
* Set the set point.
|
||||
*
|
||||
* @param sp The set point as a real world value.
|
||||
*/
|
||||
void setSetPoint(float sp);
|
||||
|
||||
/**
|
||||
* Set the process value.
|
||||
*
|
||||
* @param pv The process value as a real world value.
|
||||
*/
|
||||
void setProcessValue(float pv);
|
||||
|
||||
/**
|
||||
* Set the bias.
|
||||
*
|
||||
* @param bias The bias for the controller output.
|
||||
*/
|
||||
void setBias(float bias);
|
||||
|
||||
/**
|
||||
* PID calculation.
|
||||
*
|
||||
* @return The controller output as a float between outMin and outMax.
|
||||
*/
|
||||
float compute(void);
|
||||
|
||||
//Getters.
|
||||
float getInMin();
|
||||
float getInMax();
|
||||
float getOutMin();
|
||||
float getOutMax();
|
||||
float getInterval();
|
||||
float getPParam();
|
||||
float getIParam();
|
||||
float getDParam();
|
||||
|
||||
private:
|
||||
|
||||
bool usingFeedForward;
|
||||
bool inAuto;
|
||||
|
||||
//Actual tuning parameters used in PID calculation.
|
||||
float Kc_;
|
||||
float tauR_;
|
||||
float tauD_;
|
||||
|
||||
//Raw tuning parameters.
|
||||
float pParam_;
|
||||
float iParam_;
|
||||
float dParam_;
|
||||
|
||||
//The point we want to reach.
|
||||
float setPoint_;
|
||||
//The thing we measure.
|
||||
float processVariable_;
|
||||
float prevProcessVariable_;
|
||||
//The output that affects the process variable.
|
||||
float controllerOutput_;
|
||||
float prevControllerOutput_;
|
||||
|
||||
//We work in % for calculations so these will scale from
|
||||
//real world values to 0-100% and back again.
|
||||
float inMin_;
|
||||
float inMax_;
|
||||
float inSpan_;
|
||||
float outMin_;
|
||||
float outMax_;
|
||||
float outSpan_;
|
||||
|
||||
//The accumulated error, i.e. integral.
|
||||
float accError_;
|
||||
//The controller output bias.
|
||||
float bias_;
|
||||
|
||||
//The interval between samples.
|
||||
float tSample_;
|
||||
|
||||
//Controller output as a real world value.
|
||||
volatile float realOutput_;
|
||||
|
||||
};
|
||||
|
||||
#endif /* PID_H */
|
||||
Reference in New Issue
Block a user