Johann Rocholl
12 years ago
84 changed files with 1981 additions and 3750 deletions
File diff suppressed because it is too large
@ -0,0 +1,470 @@ |
|||
#ifndef ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H |
|||
#define ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H |
|||
|
|||
/**
|
|||
* Implementation of the LCD display routines for a hitachi HD44780 display. These are common LCD character displays. |
|||
* When selecting the rusian language, a slightly different LCD implementation is used to handle UTF8 characters. |
|||
**/ |
|||
|
|||
#if LANGUAGE_CHOICE == 6 |
|||
#include "LiquidCrystalRus.h" |
|||
#define LCD_CLASS LiquidCrystalRus |
|||
#else |
|||
#include <LiquidCrystal.h> |
|||
#define LCD_CLASS LiquidCrystal |
|||
#endif |
|||
|
|||
/* Custom characters defined in the first 8 characters of the LCD */ |
|||
#define LCD_STR_BEDTEMP "\x00" |
|||
#define LCD_STR_DEGREE "\x01" |
|||
#define LCD_STR_THERMOMETER "\x02" |
|||
#define LCD_STR_UPLEVEL "\x03" |
|||
#define LCD_STR_REFRESH "\x04" |
|||
#define LCD_STR_FOLDER "\x05" |
|||
#define LCD_STR_FEEDRATE "\x06" |
|||
#define LCD_STR_CLOCK "\x07" |
|||
#define LCD_STR_ARROW_RIGHT "\x7E" /* from the default character set */ |
|||
|
|||
LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7
|
|||
static void lcd_implementation_init() |
|||
{ |
|||
byte bedTemp[8] = |
|||
{ |
|||
B00000, |
|||
B11111, |
|||
B10101, |
|||
B10001, |
|||
B10101, |
|||
B11111, |
|||
B00000, |
|||
B00000 |
|||
}; //thanks Sonny Mounicou
|
|||
byte degree[8] = |
|||
{ |
|||
B01100, |
|||
B10010, |
|||
B10010, |
|||
B01100, |
|||
B00000, |
|||
B00000, |
|||
B00000, |
|||
B00000 |
|||
}; |
|||
byte thermometer[8] = |
|||
{ |
|||
B00100, |
|||
B01010, |
|||
B01010, |
|||
B01010, |
|||
B01010, |
|||
B10001, |
|||
B10001, |
|||
B01110 |
|||
}; |
|||
byte uplevel[8]={ |
|||
B00100, |
|||
B01110, |
|||
B11111, |
|||
B00100, |
|||
B11100, |
|||
B00000, |
|||
B00000, |
|||
B00000 |
|||
}; //thanks joris
|
|||
byte refresh[8]={ |
|||
B00000, |
|||
B00110, |
|||
B11001, |
|||
B11000, |
|||
B00011, |
|||
B10011, |
|||
B01100, |
|||
B00000, |
|||
}; //thanks joris
|
|||
byte folder [8]={ |
|||
B00000, |
|||
B11100, |
|||
B11111, |
|||
B10001, |
|||
B10001, |
|||
B11111, |
|||
B00000, |
|||
B00000 |
|||
}; //thanks joris
|
|||
byte feedrate [8]={ |
|||
B11100, |
|||
B10000, |
|||
B11000, |
|||
B10111, |
|||
B00101, |
|||
B00110, |
|||
B00101, |
|||
B00000 |
|||
}; //thanks Sonny Mounicou
|
|||
byte clock [8]={ |
|||
B00000, |
|||
B01110, |
|||
B10011, |
|||
B10101, |
|||
B10001, |
|||
B01110, |
|||
B00000, |
|||
B00000 |
|||
}; //thanks Sonny Mounicou
|
|||
lcd.begin(LCD_WIDTH, LCD_HEIGHT); |
|||
lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp); |
|||
lcd.createChar(LCD_STR_DEGREE[0], degree); |
|||
lcd.createChar(LCD_STR_THERMOMETER[0], thermometer); |
|||
lcd.createChar(LCD_STR_UPLEVEL[0], uplevel); |
|||
lcd.createChar(LCD_STR_REFRESH[0], refresh); |
|||
lcd.createChar(LCD_STR_FOLDER[0], folder); |
|||
lcd.createChar(LCD_STR_FEEDRATE[0], feedrate); |
|||
lcd.createChar(LCD_STR_CLOCK[0], clock); |
|||
lcd.clear(); |
|||
} |
|||
static void lcd_implementation_clear() |
|||
{ |
|||
lcd.clear(); |
|||
} |
|||
/* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */ |
|||
static void lcd_printPGM(const char* str) |
|||
{ |
|||
char c; |
|||
while((c = pgm_read_byte(str++)) != '\0') |
|||
{ |
|||
lcd.write(c); |
|||
} |
|||
} |
|||
/*
|
|||
Possible status screens: |
|||
16x2 |0123456789012345| |
|||
|000/000 B000/000| |
|||
|Status line.....| |
|||
|
|||
16x4 |0123456789012345| |
|||
|000/000 B000/000| |
|||
|SD100% Z000.0| |
|||
|F100% T--:--| |
|||
|Status line.....| |
|||
|
|||
20x2 |01234567890123456789| |
|||
|T000/000D B000/000D | |
|||
|Status line.........| |
|||
|
|||
20x4 |01234567890123456789| |
|||
|T000/000D B000/000D | |
|||
|X+000.0 Y+000.0 Z+000.0| |
|||
|F100% SD100% T--:--| |
|||
|Status line.........| |
|||
|
|||
20x4 |01234567890123456789| |
|||
|T000/000D B000/000D | |
|||
|T000/000D Z000.0| |
|||
|F100% SD100% T--:--| |
|||
|Status line.........| |
|||
*/ |
|||
static void lcd_implementation_status_screen() |
|||
{ |
|||
int tHotend=int(degHotend(0) + 0.5); |
|||
int tTarget=int(degTargetHotend(0) + 0.5); |
|||
|
|||
#if LCD_WIDTH < 20 |
|||
lcd.setCursor(0, 0); |
|||
lcd.print(itostr3(tHotend)); |
|||
lcd.print('/'); |
|||
lcd.print(itostr3left(tTarget)); |
|||
|
|||
# if EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 |
|||
//If we have an 2nd extruder or heated bed, show that in the top right corner
|
|||
lcd.setCursor(8, 0); |
|||
# if EXTRUDERS > 1 |
|||
tHotend = int(degHotend(1) + 0.5); |
|||
tTarget = int(degTargetHotend(1) + 0.5); |
|||
lcd.print(LCD_STR_THERMOMETER[0]); |
|||
# else//Heated bed
|
|||
tHotend=int(degBed() + 0.5); |
|||
tTarget=int(degTargetBed() + 0.5); |
|||
lcd.print(LCD_STR_BEDTEMP[0]); |
|||
# endif |
|||
lcd.print(itostr3(tHotend)); |
|||
lcd.print('/'); |
|||
lcd.print(itostr3left(tTarget)); |
|||
# endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
|
|||
|
|||
#else//LCD_WIDTH > 19
|
|||
lcd.setCursor(0, 0); |
|||
lcd.print(LCD_STR_THERMOMETER[0]); |
|||
lcd.print(itostr3(tHotend)); |
|||
lcd.print('/'); |
|||
lcd.print(itostr3left(tTarget)); |
|||
lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); |
|||
|
|||
# if EXTRUDERS > 1 || TEMP_SENSOR_BED != 0 |
|||
//If we have an 2nd extruder or heated bed, show that in the top right corner
|
|||
lcd.setCursor(10, 0); |
|||
# if EXTRUDERS > 1 |
|||
tHotend = int(degHotend(1) + 0.5); |
|||
tTarget = int(degTargetHotend(1) + 0.5); |
|||
lcd.print(LCD_STR_THERMOMETER[0]); |
|||
# else//Heated bed
|
|||
tHotend=int(degBed() + 0.5); |
|||
tTarget=int(degTargetBed() + 0.5); |
|||
lcd.print(LCD_STR_BEDTEMP[0]); |
|||
# endif |
|||
lcd.print(itostr3(tHotend)); |
|||
lcd.print('/'); |
|||
lcd.print(itostr3left(tTarget)); |
|||
lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); |
|||
# endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
|
|||
#endif//LCD_WIDTH > 19
|
|||
|
|||
#if LCD_HEIGHT > 2 |
|||
//Lines 2 for 4 line LCD
|
|||
# if LCD_WIDTH < 20 |
|||
# ifdef SDSUPPORT |
|||
lcd.setCursor(0, 2); |
|||
lcd_printPGM(PSTR("SD")); |
|||
if (IS_SD_PRINTING) |
|||
lcd.print(itostr3(card.percentDone())); |
|||
else |
|||
lcd_printPGM(PSTR("---")); |
|||
lcd.print('%'); |
|||
# endif//SDSUPPORT
|
|||
# else//LCD_WIDTH > 19
|
|||
# if EXTRUDERS > 1 && TEMP_SENSOR_BED != 0 |
|||
//If we both have a 2nd extruder and a heated bed, show the heated bed temp on the 2nd line on the left, as the first line is filled with extruder temps
|
|||
tHotend=int(degBed() + 0.5); |
|||
tTarget=int(degTargetBed() + 0.5); |
|||
|
|||
lcd.setCursor(0, 1); |
|||
lcd.print(LCD_STR_BEDTEMP[0]); |
|||
lcd.print(itostr3(tHotend)); |
|||
lcd.print('/'); |
|||
lcd.print(itostr3left(tTarget)); |
|||
lcd_printPGM(PSTR(LCD_STR_DEGREE " ")); |
|||
# else |
|||
lcd.setCursor(0,1); |
|||
lcd.print('X'); |
|||
lcd.print(ftostr3(current_position[X_AXIS])); |
|||
lcd_printPGM(PSTR(" Y")); |
|||
lcd.print(ftostr3(current_position[Y_AXIS])); |
|||
# endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
|
|||
# endif//LCD_WIDTH > 19
|
|||
lcd.setCursor(LCD_WIDTH - 7, 1); |
|||
lcd.print('Z'); |
|||
lcd.print(ftostr31(current_position[Z_AXIS])); |
|||
#endif//LCD_HEIGHT > 2
|
|||
|
|||
#if LCD_HEIGHT > 3 |
|||
lcd.setCursor(0, 2); |
|||
lcd.print(LCD_STR_FEEDRATE[0]); |
|||
lcd.print(itostr3(feedmultiply)); |
|||
lcd.print('%'); |
|||
# if LCD_WIDTH > 19 |
|||
# ifdef SDSUPPORT |
|||
lcd.setCursor(7, 2); |
|||
lcd_printPGM(PSTR("SD")); |
|||
if (IS_SD_PRINTING) |
|||
lcd.print(itostr3(card.percentDone())); |
|||
else |
|||
lcd_printPGM(PSTR("---")); |
|||
lcd.print('%'); |
|||
# endif//SDSUPPORT
|
|||
# endif//LCD_WIDTH > 19
|
|||
lcd.setCursor(LCD_WIDTH - 6, 2); |
|||
lcd.print(LCD_STR_CLOCK[0]); |
|||
if(starttime != 0) |
|||
{ |
|||
uint16_t time = millis()/60000 - starttime/60000; |
|||
lcd.print(itostr2(time/60)); |
|||
lcd.print(':'); |
|||
lcd.print(itostr2(time%60)); |
|||
}else{ |
|||
lcd_printPGM(PSTR("--:--")); |
|||
} |
|||
#endif |
|||
|
|||
//Status message line on the last line
|
|||
lcd.setCursor(0, LCD_HEIGHT - 1); |
|||
lcd.print(lcd_status_message); |
|||
} |
|||
static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) |
|||
{ |
|||
char c; |
|||
uint8_t n = LCD_WIDTH - 1 - 2; |
|||
lcd.setCursor(0, row); |
|||
lcd.print(pre_char); |
|||
while((c = pgm_read_byte(pstr)) != '\0') |
|||
{ |
|||
lcd.print(c); |
|||
pstr++; |
|||
n--; |
|||
} |
|||
while(n--) |
|||
lcd.print(' '); |
|||
lcd.print(post_char); |
|||
lcd.print(' '); |
|||
} |
|||
static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, char* data) |
|||
{ |
|||
char c; |
|||
uint8_t n = LCD_WIDTH - 1 - 2 - strlen(data); |
|||
lcd.setCursor(0, row); |
|||
lcd.print(pre_char); |
|||
while((c = pgm_read_byte(pstr)) != '\0') |
|||
{ |
|||
lcd.print(c); |
|||
pstr++; |
|||
n--; |
|||
} |
|||
lcd.print(':'); |
|||
while(n--) |
|||
lcd.print(' '); |
|||
lcd.print(data); |
|||
} |
|||
static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, const char* pstr, char pre_char, const char* data) |
|||
{ |
|||
char c; |
|||
uint8_t n = LCD_WIDTH - 1 - 2 - strlen_P(data); |
|||
lcd.setCursor(0, row); |
|||
lcd.print(pre_char); |
|||
while((c = pgm_read_byte(pstr)) != '\0') |
|||
{ |
|||
lcd.print(c); |
|||
pstr++; |
|||
n--; |
|||
} |
|||
lcd.print(':'); |
|||
while(n--) |
|||
lcd.print(' '); |
|||
lcd_printPGM(data); |
|||
} |
|||
#define lcd_implementation_drawmenu_setting_edit_int3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data))) |
|||
#define lcd_implementation_drawmenu_setting_edit_int3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data))) |
|||
#define lcd_implementation_drawmenu_setting_edit_float3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data))) |
|||
#define lcd_implementation_drawmenu_setting_edit_float3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data))) |
|||
#define lcd_implementation_drawmenu_setting_edit_float32_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data))) |
|||
#define lcd_implementation_drawmenu_setting_edit_float32(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data))) |
|||
#define lcd_implementation_drawmenu_setting_edit_float5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data))) |
|||
#define lcd_implementation_drawmenu_setting_edit_float5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data))) |
|||
#define lcd_implementation_drawmenu_setting_edit_float52_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data))) |
|||
#define lcd_implementation_drawmenu_setting_edit_float52(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data))) |
|||
#define lcd_implementation_drawmenu_setting_edit_float51_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data))) |
|||
#define lcd_implementation_drawmenu_setting_edit_float51(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data))) |
|||
#define lcd_implementation_drawmenu_setting_edit_long5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data))) |
|||
#define lcd_implementation_drawmenu_setting_edit_long5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data))) |
|||
#define lcd_implementation_drawmenu_setting_edit_bool_selected(row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF)) |
|||
#define lcd_implementation_drawmenu_setting_edit_bool(row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, ' ', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF)) |
|||
void lcd_implementation_drawedit(const char* pstr, char* value) |
|||
{ |
|||
lcd.setCursor(0, 1); |
|||
lcd_printPGM(pstr); |
|||
lcd.print(':'); |
|||
lcd.setCursor(19 - strlen(value), 1); |
|||
lcd.print(value); |
|||
} |
|||
static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename) |
|||
{ |
|||
char c; |
|||
uint8_t n = LCD_WIDTH - 1; |
|||
lcd.setCursor(0, row); |
|||
lcd.print('>'); |
|||
if (longFilename[0] != '\0') |
|||
{ |
|||
filename = longFilename; |
|||
longFilename[LCD_WIDTH-1] = '\0'; |
|||
} |
|||
while((c = *filename) != '\0') |
|||
{ |
|||
lcd.print(c); |
|||
filename++; |
|||
n--; |
|||
} |
|||
while(n--) |
|||
lcd.print(' '); |
|||
} |
|||
static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* pstr, const char* filename, char* longFilename) |
|||
{ |
|||
char c; |
|||
uint8_t n = LCD_WIDTH - 1; |
|||
lcd.setCursor(0, row); |
|||
lcd.print(' '); |
|||
if (longFilename[0] != '\0') |
|||
{ |
|||
filename = longFilename; |
|||
longFilename[LCD_WIDTH-1] = '\0'; |
|||
} |
|||
while((c = *filename) != '\0') |
|||
{ |
|||
lcd.print(c); |
|||
filename++; |
|||
n--; |
|||
} |
|||
while(n--) |
|||
lcd.print(' '); |
|||
} |
|||
static void lcd_implementation_drawmenu_sddirectory_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename) |
|||
{ |
|||
char c; |
|||
uint8_t n = LCD_WIDTH - 2; |
|||
lcd.setCursor(0, row); |
|||
lcd.print('>'); |
|||
lcd.print(LCD_STR_FOLDER[0]); |
|||
if (longFilename[0] != '\0') |
|||
{ |
|||
filename = longFilename; |
|||
longFilename[LCD_WIDTH-2] = '\0'; |
|||
} |
|||
while((c = *filename) != '\0') |
|||
{ |
|||
lcd.print(c); |
|||
filename++; |
|||
n--; |
|||
} |
|||
while(n--) |
|||
lcd.print(' '); |
|||
} |
|||
static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pstr, const char* filename, char* longFilename) |
|||
{ |
|||
char c; |
|||
uint8_t n = LCD_WIDTH - 2; |
|||
lcd.setCursor(0, row); |
|||
lcd.print(' '); |
|||
lcd.print(LCD_STR_FOLDER[0]); |
|||
if (longFilename[0] != '\0') |
|||
{ |
|||
filename = longFilename; |
|||
longFilename[LCD_WIDTH-2] = '\0'; |
|||
} |
|||
while((c = *filename) != '\0') |
|||
{ |
|||
lcd.print(c); |
|||
filename++; |
|||
n--; |
|||
} |
|||
while(n--) |
|||
lcd.print(' '); |
|||
} |
|||
#define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0]) |
|||
#define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0]) |
|||
#define lcd_implementation_drawmenu_submenu_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', LCD_STR_ARROW_RIGHT[0]) |
|||
#define lcd_implementation_drawmenu_submenu(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_ARROW_RIGHT[0]) |
|||
#define lcd_implementation_drawmenu_gcode_selected(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ') |
|||
#define lcd_implementation_drawmenu_gcode(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ') |
|||
#define lcd_implementation_drawmenu_function_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ') |
|||
#define lcd_implementation_drawmenu_function(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ') |
|||
|
|||
static void lcd_implementation_quick_feedback() |
|||
{ |
|||
#if BEEPER > -1 |
|||
SET_OUTPUT(BEEPER); |
|||
for(int8_t i=0;i<10;i++) |
|||
{ |
|||
WRITE(BEEPER,HIGH); |
|||
delay(3); |
|||
WRITE(BEEPER,LOW); |
|||
delay(3); |
|||
} |
|||
#endif |
|||
} |
|||
#endif//ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H
|
@ -1,141 +0,0 @@ |
|||
/*
|
|||
* fixed by this patch: |
|||
* http://code.google.com/p/arduino/issues/detail?id=604
|
|||
* */ |
|||
/*
|
|||
wiring.h - Partial implementation of the Wiring API for the ATmega8. |
|||
Part of Arduino - http://www.arduino.cc/
|
|||
|
|||
Copyright (c) 2005-2006 David A. Mellis |
|||
|
|||
This library is free software; you can redistribute it and/or |
|||
modify it under the terms of the GNU Lesser General Public |
|||
License as published by the Free Software Foundation; either |
|||
version 2.1 of the License, or (at your option) any later version. |
|||
|
|||
This library is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|||
Lesser General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU Lesser General |
|||
Public License along with this library; if not, write to the |
|||
Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
|||
Boston, MA 02111-1307 USA |
|||
|
|||
$Id$ |
|||
*/ |
|||
|
|||
#ifndef Wiring_h |
|||
#define Wiring_h |
|||
|
|||
#include <avr/io.h> |
|||
#include <stdlib.h> |
|||
#include "binary.h" |
|||
|
|||
#ifdef __cplusplus |
|||
extern "C"{ |
|||
#endif |
|||
|
|||
#define HIGH 0x1 |
|||
#define LOW 0x0 |
|||
|
|||
#define INPUT 0x0 |
|||
#define OUTPUT 0x1 |
|||
|
|||
#define true 0x1 |
|||
#define false 0x0 |
|||
|
|||
#define PI 3.1415926535897932384626433832795 |
|||
#define HALF_PI 1.5707963267948966192313216916398 |
|||
#define TWO_PI 6.283185307179586476925286766559 |
|||
#define DEG_TO_RAD 0.017453292519943295769236907684886 |
|||
#define RAD_TO_DEG 57.295779513082320876798154814105 |
|||
|
|||
#define SERIAL 0x0 |
|||
#define DISPLAY 0x1 |
|||
|
|||
#define LSBFIRST 0 |
|||
#define MSBFIRST 1 |
|||
|
|||
#define CHANGE 1 |
|||
#define FALLING 2 |
|||
#define RISING 3 |
|||
|
|||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) |
|||
#define INTERNAL1V1 2 |
|||
#define INTERNAL2V56 3 |
|||
#else |
|||
#define INTERNAL 3 |
|||
#endif |
|||
#define DEFAULT 1 |
|||
#define EXTERNAL 0 |
|||
|
|||
// undefine stdlib's abs if encountered
|
|||
#ifdef abs |
|||
#undef abs |
|||
#endif |
|||
|
|||
#define min(a,b) ((a)<(b)?(a):(b)) |
|||
#define max(a,b) ((a)>(b)?(a):(b)) |
|||
#define abs(x) ((x)>0?(x):-(x)) |
|||
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) |
|||
#if __AVR_LIBC_VERSION__ < 10701UL |
|||
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) |
|||
#endif |
|||
#define radians(deg) ((deg)*DEG_TO_RAD) |
|||
#define degrees(rad) ((rad)*RAD_TO_DEG) |
|||
#define sq(x) ((x)*(x)) |
|||
|
|||
#define interrupts() sei() |
|||
#define noInterrupts() cli() |
|||
|
|||
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L ) |
|||
#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) ) |
|||
#define microsecondsToClockCycles(a) ( ((a) * (F_CPU / 1000L)) / 1000L ) |
|||
|
|||
#define lowByte(w) ((uint8_t) ((w) & 0xff)) |
|||
#define highByte(w) ((uint8_t) ((w) >> 8)) |
|||
|
|||
#define bitRead(value, bit) (((value) >> (bit)) & 0x01) |
|||
#define bitSet(value, bit) ((value) |= (1UL << (bit))) |
|||
#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) |
|||
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) |
|||
|
|||
|
|||
typedef unsigned int word; |
|||
|
|||
#define bit(b) (1UL << (b)) |
|||
|
|||
typedef uint8_t boolean; |
|||
typedef uint8_t byte; |
|||
|
|||
void init(void); |
|||
|
|||
void pinMode(uint8_t, uint8_t); |
|||
void digitalWrite(uint8_t, uint8_t); |
|||
int digitalRead(uint8_t); |
|||
int analogRead(uint8_t); |
|||
void analogReference(uint8_t mode); |
|||
void analogWrite(uint8_t, int); |
|||
|
|||
unsigned long millis(void); |
|||
unsigned long micros(void); |
|||
void delay(unsigned long); |
|||
void delayMicroseconds(unsigned int us); |
|||
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); |
|||
|
|||
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); |
|||
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); |
|||
|
|||
void attachInterrupt(uint8_t, void (*)(void), int mode); |
|||
void detachInterrupt(uint8_t); |
|||
|
|||
void setup(void); |
|||
void loop(void); |
|||
|
|||
#ifdef __cplusplus |
|||
} // extern "C"
|
|||
#endif |
|||
|
|||
#endif |
Loading…
Reference in new issue