Move to CMake

This commit is contained in:
Nathanaël Restori 2012-09-08 22:00:20 +02:00
parent 70946147fa
commit a3cfbb543f
8 changed files with 1861 additions and 10 deletions

22
arduino/CMakeLists.txt Normal file
View File

@ -0,0 +1,22 @@
set(CMAKE_TOOLCHAIN_FILE cmake/ArduinoToolchain.cmake) # Arduino Toolchain
cmake_minimum_required(VERSION 2.8)
#====================================================================#
# Setup Project #
#====================================================================#
project(WeatherStation C CXX)
set(ARDUINO_DEFAULT_BOARD uno)
set(ARDUINO_DEFAULT_PORT /dev/ttyUSB0)
set(ARDUINO_DEFAULT_SERIAL "picocom @INPUT_PORT@ -b 9600 -l")
#link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../libraries)
generate_arduino_firmware(WeatherStationLogger
SKETCH WeatherStationLogger)
generate_arduino_firmware(WeatherStationWeb
SKETCH WeatherStationWeb
BOARD uno
PORT /dev/ttyUSB1
SERIAL "picocom @INPUT_PORT@ -b 9600 -l")

View File

@ -18,6 +18,7 @@ File file;
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
pinMode(5, OUTPUT);
//----- SD Card //----- SD Card
Serial.println("INIT SD Card"); Serial.println("INIT SD Card");

View File

@ -72,7 +72,7 @@ void sensorsJsonCmd(WebServer &server, WebServer::ConnectionType type, char *url
<< "] }"; << "] }";
} }
void sendNTPpacket(IPAddress& address) { void sendNTPpacket() {
// set all bytes in the buffer to 0 // set all bytes in the buffer to 0
memset(packetBuffer, 0, NTP_PACKET_SIZE); memset(packetBuffer, 0, NTP_PACKET_SIZE);
// Initialize values needed to form NTP request // Initialize values needed to form NTP request
@ -89,7 +89,7 @@ void sendNTPpacket(IPAddress& address) {
// all NTP fields have been given values, now // all NTP fields have been given values, now
// you can send a packet requesting a timestamp: // you can send a packet requesting a timestamp:
Udp.beginPacket(address, 123); //NTP requests are to port 123 Udp.beginPacket(timeserver, 123); //NTP requests are to port 123
Udp.write(packetBuffer,NTP_PACKET_SIZE); Udp.write(packetBuffer,NTP_PACKET_SIZE);
Udp.endPacket(); Udp.endPacket();
Serial.println("Sending ntp packet"); Serial.println("Sending ntp packet");
@ -119,6 +119,8 @@ void sendNTPpacket(IPAddress& address) {
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
pinMode(5, OUTPUT);
SPI.begin();
//----- Ethernet/WebServer //----- Ethernet/WebServer
Serial.println("INIT Ethernet"); Serial.println("INIT Ethernet");
@ -148,7 +150,7 @@ void setup() {
//tsl.setTiming(TSL2561_INTEGRATIONTIME_402MS); // longest integration time (dim light) //tsl.setTiming(TSL2561_INTEGRATIONTIME_402MS); // longest integration time (dim light)
Udp.begin(8888); Udp.begin(8888);
sendNTPpacket(timeserver); sendNTPpacket();
} }
void loop() { void loop() {

View File

@ -0,0 +1,65 @@
#=============================================================================#
# Author: Tomasz Bogdal (QueezyTheGreat)
# Home: https://github.com/queezythegreat/arduino-cmake
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
#=============================================================================#
set(CMAKE_SYSTEM_NAME Arduino)
set(CMAKE_C_COMPILER avr-gcc)
set(CMAKE_CXX_COMPILER avr-g++)
# Add current directory to CMake Module path automatically
if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/Platform/Arduino.cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR})
endif()
#=============================================================================#
# System Paths #
#=============================================================================#
if(UNIX)
include(Platform/UnixPaths)
if(APPLE)
list(APPEND CMAKE_SYSTEM_PREFIX_PATH ~/Applications
/Applications
/Developer/Applications
/sw # Fink
/opt/local) # MacPorts
endif()
elseif(WIN32)
include(Platform/WindowsPaths)
endif()
#=============================================================================#
# Detect Arduino SDK #
#=============================================================================#
if(NOT ARDUINO_SDK_PATH)
set(ARDUINO_PATHS)
foreach(VERSION 22 1)
list(APPEND ARDUINO_PATHS arduino-00${VERSION})
endforeach()
file(GLOB SDK_PATH_HINTS /usr/share/arduino*
/opt/local/ardiuno*
/usr/local/share/arduino*)
list(SORT SDK_PATH_HINTS)
list(REVERSE SDK_PATH_HINTS)
endif()
find_path(ARDUINO_SDK_PATH
NAMES lib/version.txt
PATH_SUFFIXES share/arduino
Arduino.app/Contents/Resources/Java/
${ARDUINO_PATHS}
HINTS ${SDK_PATH_HINTS}
DOC "Arduino SDK path.")
if(ARDUINO_SDK_PATH)
list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${ARDUINO_SDK_PATH}/hardware/tools/avr/bin)
list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${ARDUINO_SDK_PATH}/hardware/tools/avr/utils/bin)
else()
message(FATAL_ERROR "Could not find Arduino SDK (set ARDUINO_SDK_PATH)!")
endif()

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,8 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// utility code, some of this could be exposed in the DateTime API if needed // utility code, some of this could be exposed in the DateTime API if needed
static uint8_t daysInMonth [] PROGMEM = { 31,28,31,30,31,30,31,31,30,31,30,31 }; //static uint8_t daysInMonth [] PROGMEM = { 31,28,31,30,31,30,31,31,30,31,30,31 };
static const uint8_t daysInMonth [] PROGMEM = { 31,28,31,30,31,30,31,31,30,31,30,31 }; // Modified
// number of days since 2000/01/01, valid for 2001..2099 // number of days since 2000/01/01, valid for 2001..2099
static uint16_t date2days(uint16_t y, uint8_t m, uint8_t d) { static uint16_t date2days(uint16_t y, uint8_t m, uint8_t d) {

View File

@ -123,7 +123,7 @@
extern "C" unsigned long millis(void); extern "C" unsigned long millis(void);
// declare a static string // declare a static string
#define P(name) static const prog_uchar name[] PROGMEM #define P(name) static const char name[] PROGMEM
// returns the number of elements in the array // returns the number of elements in the array
#define SIZE(array) (sizeof(array) / sizeof(*array)) #define SIZE(array) (sizeof(array) / sizeof(*array))
@ -189,13 +189,13 @@ public:
// output a string stored in program memory, usually one defined // output a string stored in program memory, usually one defined
// with the P macro // with the P macro
void printP(const prog_uchar *str); void printP(const char *str);
// inline overload for printP to handle signed char strings // inline overload for printP to handle signed char strings
void printP(const prog_char *str) { printP((prog_uchar*)str); } //void printP(const char *str) { printP((char*)str); }
// output raw data stored in program memory // output raw data stored in program memory
void writeP(const prog_uchar *data, size_t length); void writeP(const char *data, size_t length);
// output HTML for a radio button // output HTML for a radio button
void radioButton(const char *name, const char *val, void radioButton(const char *name, const char *val,
@ -374,7 +374,7 @@ size_t WebServer::write(const char *buffer, size_t length)
return m_client.write((const uint8_t *)buffer, length); return m_client.write((const uint8_t *)buffer, length);
} }
void WebServer::writeP(const prog_uchar *data, size_t length) void WebServer::writeP(const char *data, size_t length)
{ {
// copy data out of program memory into local storage, write out in // copy data out of program memory into local storage, write out in
// chunks of 32 bytes to avoid extra short TCP/IP packets // chunks of 32 bytes to avoid extra short TCP/IP packets
@ -396,7 +396,7 @@ void WebServer::writeP(const prog_uchar *data, size_t length)
m_client.write(buffer, bufferEnd); m_client.write(buffer, bufferEnd);
} }
void WebServer::printP(const prog_uchar *str) void WebServer::printP(const char *str)
{ {
// copy data out of program memory into local storage, write out in // copy data out of program memory into local storage, write out in
// chunks of 32 bytes to avoid extra short TCP/IP packets // chunks of 32 bytes to avoid extra short TCP/IP packets