Mpide 0023 Compatibility

This commit is contained in:
piccaso committed 2012-03-05 10:24:41 +01:00
1 parent d59f9248d1
commit 4457aca2b3
10 files changed
+25 -260

No files matched your search

+3 -6
View File
@@ -156,10 +156,8 @@ void fio_shiftOut1_init(fio_register shift1Register, fio_bit shift1Bit)
void fio_shiftOut1(fio_register shift1Register, fio_bit shift1Bit, uint8_t value,
boolean noLatch)
{
// disable interrupts since timing is going to be critical
uint8_t oldSREG;
oldSREG = SREG;
cli();
//TODO: Adapt changes from _rb
// iterate but ignore last bit (is it correct now?)
for(int8_t i = 7; i>=0; --i)
@@ -202,8 +200,7 @@ void fio_shiftOut1(fio_register shift1Register, fio_bit shift1Bit, uint8_t value
delayMicroseconds(110);
}
// enable interrupts
SREG = oldSREG;
}
void fio_shiftOut1(uint8_t pin, uint8_t value, boolean noLatch)
+13 -6
View File
@@ -27,8 +27,8 @@
// (https://github.com/chipKIT32/chipKIT32-MAX/blob/master/hardware/pic32/
// cores/pic32/wiring_digital.c)
// ---------------------------------------------------------------------------
#ifndef FAST_IO_H
#define FAST_IO_H
#ifndef _FAST_IO_H_
#define _FAST_IO_H_
#if (ARDUINO < 100)
#include <WProgram.h>
@@ -39,6 +39,10 @@
#include <pins_arduino.h> // pleasing sanguino core
#include <inttypes.h>
#ifdef __AVR__
#include <util/atomic.h> // for critical section management
#endif
/*!
@defined
@@ -47,10 +51,8 @@
*/
#ifndef __AVR__
#define FIO_FALLBACK
#define ATOMIC_BLOCK
#define ATOMIC_BLOCK(dummy) if(true)
#define ATOMIC_RESTORESTATE
#else
#include <util/atomic.h> // for critical section management
#endif
// PUBLIC CONSTANTS DEFINITIONS
@@ -66,12 +68,17 @@
// ---------------------------------------------------------------------------
typedef uint8_t fio_bit;
/*!
@typedef
@abstract Type definitions for FAST_IOs o NATIVE IDE IO
@field fio_register: IO control register
*/
#ifndef FIO_FALLBACK
typedef volatile uint8_t *fio_register;
#else
// remove volatile to give optimizer a chance
typedef uint8_t fio_register;
typedef uint8_t *fio_register;
#endif
/*!
+6 -1
View File
@@ -31,7 +31,12 @@
#endif
#include <inttypes.h>
#include "../Wire/Wire.h"
#if (__IN_ECLIPSE__)
//TODO: Find a way for eclipse to play along nicer with Wire library
#include <Wire/Wire.h>
#else
#include <Wire.h>
#endif
#include "I2CIO.h"
@@ -1,3 +1,4 @@
#include <Wire.h>
#include <LiquidCrystal_SR.h>
LiquidCrystal_SR lcd(8,7,TWO_WIRE);
@@ -17,7 +18,7 @@ void setup(){
lcd.createChar (1, armsDown); // load character to the LCD
lcd.home (); // go home
lcd.print(F("LiquidCrystal_SR"));
lcd.print("LiquidCrystal_SR");
}
void loop(){
@@ -31,5 +32,5 @@ void showHappyGuy(int pos){
lcd.print(char(random(0,2))); // show one of the two custom characters
delay(150); // wait so it can be seen
lcd.setCursor ( pos, 1 ); // go to position again
lcd.print(F(" ")); // delete character
lcd.print(" "); // delete character
}
-243
View File
@@ -1,243 +0,0 @@
// ---------------------------------------------------------------------------
// Created by Francisco Malpartida on 1/1/12.
// Copyright 2011 - Under creative commons license:
// Attribution-NonCommercial-ShareAlike CC BY-NC-SA
//
// This software is furnished "as is", without technical support, and with no
// warranty, express or implied, as to its usefulness for any purpose.
//
// Thread Safe: No
// Extendable: Yes
//
// @file i2CLCDextraIO.pde
// Temperature logging to demonstrate the I2CLCDextraIO library.
//
// @brief This application is a demostration file for the I2CLCDextraIO library
// that reads a temperature from the internal ATMEGA328p temperature sensor
// and displays it on the LCD. The application also demonstrates some of the
// methods of the library, such as loading custom characters to the LCD,
// moving around the LCD, and writing to it.
//
// @author F. Malpartida
// ---------------------------------------------------------------------------
#include <Arduino.h>
#include <Wire.h>
#include <LCD.h>
#define _LCD_I2C_
#ifdef _LCD_I2C_
#include <LiquidCrystal_I2C.h>
#endif
#ifdef _LCD_4BIT_
#include <LiquidCrystal.h>
#endif
/*!
@defined CHAR_WIDTH
@abstract Character witdth of the display, expressed in pixeles per character.
*/
#define CHAR_WIDTH 5
/*!
@defined BACKLIGHT_PIN
@abstract LCD backlight pin definition.
@discussion AVR pin used for the backlight illumintation of the LCD.
*/
#define BACKLIGHT_PIN 12
/*!
@defined TEMP_CAL_OFFSET
@abstract Temperature calibration offset.
@discussion This is the offset value that has to be modified to get a
correct temperature reading from the internal temperature sensor
of your AVR.
*/
#define TEMP_CAL_OFFSET 334
/*!
@defined FILTER_ALP
@abstract Low pass filter alpha value
@discussion This value defines how much does the current reading, influences
the over all value. The smaller, the less influence the current
reading has over the overall result.
*/
#define FILTER_ALP 0.1
extern unsigned int __bss_end;
extern unsigned int __heap_start;
extern void *__brkval;
#ifdef _LCD_I2C_
LiquidCrystal_I2C lcd(0x38); // set the LCD address to 0x20 for a 16 chars and 2 line display
#endif
#ifdef _LCD_4BIT_
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int CONTRAST_PIN = 9;
const int CONTRAST = 65;
#endif
LCD *myLCD = &lcd;
static double tempFilter;
/*!
@const charBitmap
@abstract Define Character bitmap for the bargraph.
@discussion Defines a character bitmap to represent a bargraph on a text
display. The bitmap goes from a blank character to full black.
*/
const uint8_t charBitmap[][8] = {
{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 },
{ 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0 },
{ 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0 },
{ 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0 },
{ 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x0 },
{ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0 },
{ 0xe, 0x11, 0x11, 0x11, 0xe, 0, 0, 0 },
{ 0x6, 0x9, 0x9, 0x6, 0x0, 0, 0, 0}
};
/*!
@function
@abstract Return available RAM memory
@discussion This routine returns the ammount of RAM memory available after
initialising the C runtime.
@param
@result Free RAM available.
*/
static int freeMemory()
{
int free_memory;
if((int)__brkval == 0)
free_memory = ((int)&free_memory) - ((int)&__bss_end);
else
free_memory = ((int)&free_memory) - ((int)__brkval);
return free_memory;
}
/*!
@function
@abstract Returns AVR328p internal temperature
@discussion Configures the ADC MUX for the temperature ADC channel and
waits for conversion and returns the value of the ADC module
@result The internal temperature reading - in degrees C
*/
static int readTemperature()
{
ADMUX = 0xC8; // activate interal temperature sensor,
// using 1.1V ref. voltage
ADCSRA |= _BV(ADSC); // start the conversion
while (bit_is_set(ADCSRA, ADSC)); // ADSC is cleared when the conversion
// finishes
// combine bytes & correct for temperature offset (approximate)
return ( (ADCL | (ADCH << 8)) - TEMP_CAL_OFFSET);
}
/*!
@function
@abstract Braws a bargraph onto the display representing the value passed.
@discussion Draws a bargraph on the specified row using barLength characters.
@param value[in] Value to represent in the bargraph
@param row[in] Row of the LCD where to display the bargraph. Range (0, 1)
for this display.
@param barlength[in] Length of the bar, expressed in display characters.
@param start[in] Start bar character
@param end [in] End bar character
@result None
*/
static void drawBars ( int value, uint8_t row, uint8_t barLength, char start,
char end )
{
int numBars;
// Set initial titles on the display
myLCD->setCursor (0, row);
myLCD->print (start);
// Calculate the size of the bar
value = map ( value, -30, 50, 0, ( barLength ) * CHAR_WIDTH );
numBars = value / CHAR_WIDTH;
// Limit the size of the bargraph to barLength
if ( numBars > barLength )
{
numBars = barLength;
}
myLCD->setCursor ( 1, row );
// Draw the bars
while ( numBars-- )
{
myLCD->print ( char( 5 ) );
}
// Draw the fractions
numBars = value % CHAR_WIDTH;
myLCD->print ( char(numBars) );
myLCD->setCursor (barLength + 1, row);
myLCD->print (end);
}
void setup ()
{
int i;
int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));
Serial.begin ( 57600 );
analogReference ( INTERNAL );
#ifdef _LCD_4BIT_
pinMode(CONTRAST_PIN, OUTPUT);
pinMode(BACKLIGHT_PIN, OUTPUT);
#endif
digitalWrite(BACKLIGHT_PIN, HIGH);
analogWrite (CONTRAST_PIN, CONTRAST);
myLCD->begin ( 16, 2 );
// Load custom character set into CGRAM
for ( i = 0; i < charBitmapSize; i++ )
{
myLCD->createChar ( i, (uint8_t *)charBitmap[i] );
}
Serial.println ( freeMemory () );
myLCD->clear ();
myLCD->print ("Temp:");
tempFilter = readTemperature (); // Initialise the temperature Filter
}
void loop ()
{
int temp;
temp = readTemperature();
tempFilter = ( FILTER_ALP * temp) + (( 1.0 - FILTER_ALP ) * tempFilter);
myLCD->setCursor ( 8, 0 );
myLCD->print (" ");
myLCD->setCursor ( 8, 0 );
myLCD->print ( tempFilter, 1 );
myLCD->setCursor ( 12, 0 );
myLCD->print ( "\x07" );
myLCD->print ("C");
drawBars ( tempFilter, 1, 14, '-', '+' );
delay (200);
}
-1
View File
@@ -20,7 +20,6 @@
//
// @author F. Malpartida
// ---------------------------------------------------------------------------
#include <Arduino.h>
#include <Wire.h>
#include <LCD.h>
@@ -23,7 +23,6 @@
// @author F. Malpartida - fmalpartida@gmail.com
// Contribution by flo - Florian@Fida.biz - for benchmarking SR
// ---------------------------------------------------------------------------
#include <Arduino.h>
#include <Wire.h>
#define _LCD_SR1_