1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-02 13:24:12 +01:00

Factored out print() and println() from HardwareSerial to a base class for sharing with other things (e.g. LiquidCrystal library), eliminating #include's of avr/signal.h (deprecated). Upping version number and modifying to do list.

This commit is contained in:
David A. Mellis 2008-04-18 18:39:02 +00:00
parent 154809dcee
commit ab644804ac
10 changed files with 80 additions and 293 deletions

View File

@ -53,8 +53,8 @@ import processing.core.*;
* files and images, etc) that comes from that.
*/
public class Base {
static final int VERSION = 10;
static final String VERSION_NAME = "0011 Alpha";
static final int VERSION = 12;
static final String VERSION_NAME = "0012 Alpha";
/**
* Path of filename opened on the command line,

View File

@ -56,7 +56,7 @@
productName = App;
productReference = 33DD8FB6096AC8DA0013AF8F /* Arduino.app */;
productSettingsXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
<plist version=\"1.0\">
<dict>
<key>CFBundleDevelopmentRegion</key>
@ -687,7 +687,6 @@
33FFFD3F0965B1E40016AC38 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 33FFFD400965B1E40016AC38 /* Build configuration list for PBXProject "Arduino" */;
compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 0;
mainGroup = 33FFFD3D0965B1E40016AC38;
productRefGroup = 33FFFD3D0965B1E40016AC38;

View File

@ -26,16 +26,13 @@
#include "HardwareSerial.h"
void HardwareSerialWrite(uint8_t value, void *instance) {
((HardwareSerial *) instance)->write(value);
}
// Constructors ////////////////////////////////////////////////////////////////
HardwareSerial::HardwareSerial(uint8_t uart)
{
//if(uart == 0){
// _uart = 0;
//}else{
// _uart = 1;
//}
}
HardwareSerial::HardwareSerial() : Print(HardwareSerialWrite) {}
// Public Methods //////////////////////////////////////////////////////////////
@ -59,118 +56,11 @@ void HardwareSerial::flush()
serialFlush();
}
void HardwareSerial::print(char c)
{
printByte(c);
}
void HardwareSerial::print(const char c[])
{
printString(c);
}
void HardwareSerial::print(uint8_t b)
{
printByte(b);
}
void HardwareSerial::print(int n)
{
print((long) n);
}
void HardwareSerial::print(unsigned int n)
{
print((unsigned long) n);
}
void HardwareSerial::print(long n)
{
if (n < 0) {
print('-');
n = -n;
}
printNumber(n, 10);
}
void HardwareSerial::print(unsigned long n)
{
printNumber(n, 10);
}
void HardwareSerial::print(long n, int base)
{
if (base == 0)
print((char) n);
else if (base == 10)
print(n);
else
printNumber(n, base);
}
void HardwareSerial::println(void)
{
print('\r');
print('\n');
}
void HardwareSerial::println(char c)
{
print(c);
println();
}
void HardwareSerial::println(const char c[])
{
print(c);
println();
}
void HardwareSerial::println(uint8_t b)
{
print(b);
println();
}
void HardwareSerial::println(int n)
{
print(n);
println();
}
void HardwareSerial::println(unsigned int n)
{
print(n);
println();
}
void HardwareSerial::println(long n)
{
print(n);
println();
}
void HardwareSerial::println(unsigned long n)
{
print(n);
println();
}
void HardwareSerial::println(long n, int base)
{
print(n, base);
println();
}
// Private Methods /////////////////////////////////////////////////////////////
void HardwareSerial::printNumber(unsigned long n, uint8_t base)
{
printIntegerInBase(n, base);
void HardwareSerial::write(uint8_t b) {
serialWrite(b);
}
// Preinstantiate Objects //////////////////////////////////////////////////////
HardwareSerial Serial = HardwareSerial(0);
//HardwareSerial Serial1 = HardwareSerial(1);
HardwareSerial Serial = HardwareSerial();

View File

@ -22,44 +22,20 @@
#include <inttypes.h>
#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2
#define BYTE 0
#include "Print.h"
class HardwareSerial
class HardwareSerial : public Print
{
private:
//uint8_t _uart;
void printNumber(unsigned long, uint8_t);
public:
HardwareSerial(uint8_t);
HardwareSerial();
void begin(long);
uint8_t available(void);
int read(void);
void flush(void);
void print(char);
void print(const char[]);
void print(uint8_t);
void print(int);
void print(unsigned int);
void print(long);
void print(unsigned long);
void print(long, int);
void println(void);
void println(char);
void println(const char[]);
void println(uint8_t);
void println(int);
void println(unsigned int);
void println(long);
void println(unsigned long);
void println(long, int);
void write(uint8_t);
};
extern HardwareSerial Serial;
//extern HardwareSerial Serial1;
#endif

View File

@ -26,7 +26,6 @@
#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#include <avr/pgmspace.h>
#include <stdio.h>

View File

@ -3,7 +3,6 @@
#include <math.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#include "wiring.h"

View File

@ -27,7 +27,6 @@
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#include <avr/delay.h>
#include <stdio.h>
#include <stdarg.h>

View File

@ -126,87 +126,4 @@ SIGNAL(SIG_UART_RECV)
rx_buffer[rx_buffer_head] = c;
rx_buffer_head = i;
}
}
void printMode(int mode)
{
// do nothing, we only support serial printing, not lcd.
}
void printByte(unsigned char c)
{
serialWrite(c);
}
void printNewline()
{
printByte('\n');
}
void printString(const char *s)
{
while (*s)
printByte(*s++);
}
void printIntegerInBase(unsigned long n, unsigned long base)
{
unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
unsigned long i = 0;
if (n == 0) {
printByte('0');
return;
}
while (n > 0) {
buf[i++] = n % base;
n /= base;
}
for (; i > 0; i--)
printByte(buf[i - 1] < 10 ?
'0' + buf[i - 1] :
'A' + buf[i - 1] - 10);
}
void printInteger(long n)
{
if (n < 0) {
printByte('-');
n = -n;
}
printIntegerInBase(n, 10);
}
void printHex(unsigned long n)
{
printIntegerInBase(n, 16);
}
void printOctal(unsigned long n)
{
printIntegerInBase(n, 8);
}
void printBinary(unsigned long n)
{
printIntegerInBase(n, 2);
}
/* Including print() adds approximately 1500 bytes to the binary size,
* so we replace it with the smaller and less-confusing printString(),
* printInteger(), etc.
void print(const char *format, ...)
{
char buf[256];
va_list ap;
va_start(ap, format);
vsnprintf(buf, 256, format, ap);
va_end(ap);
printString(buf);
}
*/
}

View File

@ -22,7 +22,6 @@
#include <inttypes.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#include <compat/twi.h>
#ifndef cbi

119
todo.txt
View File

@ -1,64 +1,54 @@
0011 arduino
0011
Improve preprocessing of sketches:
- Better determine which header files are included (not commented out).
- Remember the original locations of function prototypes to highlight the correct line on error.
- [done] Insert prototypes at a better spot in the code (after pre-processor directives).
- [done] Don't move #include statements.
- [done] Better determine which functions need prototypes
Update version of the FTDI drivers (Windows).
Move AVR ISP and giveio drivers elsewhere (Windows).
Add #defines for the analog input pins.
Deal with shorter screens (e.g. ASUS EEPC).
[done] Add timeout parameter to pulseIn().
[done] Update version of the FTDI drivers (Mac).
[done] Allow disabling of serial flushing before upload (for the Arduino BT).
[done] Modify parallel port programmer burning (add -F, lower or remove delay).
[done] Allow uploading using a hardware programmer.
[done] Add analogReference() function.
[done] Add miscellaneous #defines (interrupts(), int(), etc.)
[done] Add map() function.
[done] Fix find in reference.
[done] Include stable version of Firmata in hardware/firmwares.
0012 arduino
AVR
Add parameter to shiftOut() for specifying a number of bits.
Add parameter to Serial.print[ln](x, BYTE) for specifying number of bits.
Add support for ATmega1280 (e.g. timers, external interrupts, multiple serial ports).
Add weak attribute to signal handlers (http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1203798214)
Incorporate ladyada's new SoftwareSerial library.
Good way to receive multiple values / complex messages over the serial port.
Floating point support in the map() function.
Fix millis() so it overflows on a nice variable-size boundary; see: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1205949448
Consider moving millis() to timer 1, and configuring it so the interrupt is generated once a millisecond.
Problems including WProgram.h twice?
Add #defines for the analog input pins.
Add parameter to shiftOut() for specifying a number of bits.
Add parameter to Serial.print[ln](x, BIN) for specifying number of bits.
Factor out print statements into a common base class for Serial, LiquidCrystal, etc.
Add support for ATmega1280 (e.g. timers, external interrupts, multiple serial ports).
Add weak attribute to signal handlers: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1203798214
Incorporate ladyada's new SoftwareSerial library.
Good way to receive multiple values / complex messages over the serial port (Firmata?)
Floating point support in the map() function.
Way to print floats.
Wire library patch: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1206621511
Fix delayMicroseconds(0).
Add sleep function(s).
Add SPI library.
Add pulseOut(), etc. functions from Wiring.
Add String library.
Add LCD library.
Add LiquidCrystal library.
Add Servo library.
Create Encoder library (but don't include in the distribution).
Create Ping library (but don't include in the distribution).
Add Encoder library.
Add Ping example.
Add highByte(), lowByte(), and word(high, low) functions.
Add bitRead() and bitWrite() functions.
Add bitRead() and bitWrite() functions (and bitSet() and bitClear()?)
Include Arduino as AVR-ISP sketch in hardware/firmwares.
Move type definitions into WConstants.h.
Change core to use Arduino types (e.g. byte, boolean).
COMPUTER
Improve preprocessing of sketches:
- Better determine which header files are included (not commented out).
- Remember the original locations of function prototypes to highlight the correct line on error.
Multiple sketch windows.
Easier library discovery and installation.
Easier board installation.
Clean up Library and LibraryManager.
Byte-based serial monitor.
Clear character should clear serial monitor.
Incorporate serial-net proxy.
Changing font size should change serial monitor font size.
Deal with shorter screens (e.g. ASUS EEPC).
Investigate method for auto-detecting serial port on Windows.
Guess serial port on the Mac and Linux.
Automatic detection of baud rate for serial monitor (based on the call to Serial.begin() in the current sketch).
Improve, generally, the upload experience (e.g. faster program start after upload, keep-alive messages to bootloader from IDE, shorter bootloader timeout if possible, progress bar)
Enable drag-and-drop of .pde files to Arduino dock icon.
Allow uploading of .hex files.
Per-board upload.using preference.
Allow for arbitrary compilation command line arguments.
@ -67,35 +57,54 @@ Test find in reference on libraries.
DEVELOPMENT
Update version of the FTDI drivers (Windows).
Remove AVR ISP and giveio drivers (Windows).
Include the executable installer for the FTDI drivers (Windows).
Include newer version of avr-gcc (one that supports the ATmega1280).
Revise fetch.sh to look for version specific pages (names suffixed with, e.g., "-0007")
If possible, install bug tracking and svn on arduino.cc.
Move to ant for build process (limitations: can't build bootloader, can't build Windows arduino.exe, etc.)
Move to ant for build process.
DOCUMENTATION
DOCUMENTATION / SITE CONFIGURATION
Get good top-down, well-lit, plain-white-background photos of the Arduino boards.
Electronics reference a la Wiring.
Documentation for moving from Arduino to custom PCBs.
Examples should demonstrate use of functions.
Add examples using specific hardware.
Programming tutorial for Arduino.
Write advanced library tutorial.
Multi-language plugin.
Work on opening up website to public editing.
Document optocoupler.
Replace rainbow diagram on the guide to the board page.
Upload photo of single sided Arduino board.
Update pictures to use Arduino Diecimila: Guide/Board, tutorials,
Create an example for using a simple analog sensor like an LDR, PWM.
Create diagrams and schematics for the examples.
Create community section of site.
Create form for submitting workshops.
Create form for submitting projects.
Create community to do list.
Getting Started:
DOCUMENTATION / META
Create community to do list.
Create community section of site.
List of examples we'd like to have.
Style guide for examples, references, and foundations.
DOCUMENTATION / NAVIGATION
Move navigation to a toolbar at the top of the page.
Reorganize sub-menus (create sub-sections).
Not clear where some things go: foundations, environment, etc.
DOCUMENTATION / CONTENTS
Add examples using specific hardware (simple analog sensors, optocouplers, etc.)
Get good top-down, well-lit, plain-white-background photos of the Arduino boards.
Documentation for moving from Arduino to custom PCBs.
Examples should demonstrate use of functions.
Arduino feature list (in Getting Started > Introduction).
Programming tutorial for Arduino.
Write advanced library tutorial.
DOCUMENTATION / IMAGES
Replace rainbow diagram on the guide to the board page.
Update pictures to use Arduino Diecimila: Guide/Board, tutorials,
Create diagrams and schematics for the examples.
DOCUMENTATION / GETTING STARTED
Consider deleting many of the pictures in the howto's as they just make it harder to see the instructions without adding much (e.g. the pictures of files in folders).
Tell people not to put the board on a Powerbook.
People don't know what a jumper is.
Add picture of the RX/TX LEDs flashing.
Show a picture of the LED flashing.
Show a picture of the LED flashing.