Project Autus - Automated Plant Chamber

Dependencies:   TextLCD mbed

Fork of keypad_test by Plamen Totev

Autus

This is the codebase accompanying the project Autus.

Autus is an automated growth chamber for plants.

Features

Control Humidity inside chamber wrt to external humidity. Control Temperature inside chamber. ( Peltier Heaters/Coolers ) Water and shower plants. Control soil humidity. Monitor water tanks level (Load Cell) /media/uploads/umairaftab/frdm_-_new_page1.png

Code Base Features

Fixed timing and CRC for DHT-11 Sensor. Fixed OneWire bug for ds18b20

Cyclic Executive Scheduler with Priority. Async IPC framework for PC App over bluetooth

Fake RTC systick, I was having some trouble with the on board rtc.

/media/uploads/umairaftab/download.png

Committer:
umairaftab
Date:
Mon Apr 14 19:18:14 2014 +0000
Revision:
57:7ab93ed49b70
Parent:
38:9f4107db1bff
Cosmetic Changes, Menus added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
umairaftab 38:9f4107db1bff 1 /*
umairaftab 38:9f4107db1bff 2 * OneWireCRC. This is a port to mbed of Jim Studt's Adruino One Wire
umairaftab 38:9f4107db1bff 3 * library. Please see additional copyrights below this one, including
umairaftab 38:9f4107db1bff 4 * references to other copyrights.
umairaftab 38:9f4107db1bff 5 *
umairaftab 38:9f4107db1bff 6 * Copyright (C) <2009> Petras Saduikis <petras@petras.co.uk>
umairaftab 38:9f4107db1bff 7 *
umairaftab 38:9f4107db1bff 8 * This file is part of OneWireCRC.
umairaftab 38:9f4107db1bff 9 *
umairaftab 38:9f4107db1bff 10 * OneWireCRC is free software: you can redistribute it and/or modify
umairaftab 38:9f4107db1bff 11 * it under the terms of the GNU General Public License as published by
umairaftab 38:9f4107db1bff 12 * the Free Software Foundation, either version 3 of the License, or
umairaftab 38:9f4107db1bff 13 * (at your option) any later version.
umairaftab 38:9f4107db1bff 14 *
umairaftab 38:9f4107db1bff 15 * OneWireCRC is distributed in the hope that it will be useful,
umairaftab 38:9f4107db1bff 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
umairaftab 38:9f4107db1bff 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
umairaftab 38:9f4107db1bff 18 * GNU General Public License for more details.
umairaftab 38:9f4107db1bff 19 *
umairaftab 38:9f4107db1bff 20 * You should have received a copy of the GNU General Public License
umairaftab 38:9f4107db1bff 21 * along with OneWireCRC. If not, see <http://www.gnu.org/licenses/>.
umairaftab 38:9f4107db1bff 22 */
umairaftab 38:9f4107db1bff 23 /*
umairaftab 38:9f4107db1bff 24 Copyright (c) 2007, Jim Studt
umairaftab 38:9f4107db1bff 25
umairaftab 38:9f4107db1bff 26 Updated to work with arduino-0008 and to include skip() as of
umairaftab 38:9f4107db1bff 27 2007/07/06. --RJL20
umairaftab 38:9f4107db1bff 28
umairaftab 38:9f4107db1bff 29 Modified to calculate the 8-bit CRC directly, avoiding the need for
umairaftab 38:9f4107db1bff 30 the 256-byte lookup table to be loaded in RAM. Tested in arduino-0010
umairaftab 38:9f4107db1bff 31 -- Tom Pollard, Jan 23, 2008
umairaftab 38:9f4107db1bff 32
umairaftab 38:9f4107db1bff 33 Permission is hereby granted, free of charge, to any person obtaining
umairaftab 38:9f4107db1bff 34 a copy of this software and associated documentation files (the
umairaftab 38:9f4107db1bff 35 "Software"), to deal in the Software without restriction, including
umairaftab 38:9f4107db1bff 36 without limitation the rights to use, copy, modify, merge, publish,
umairaftab 38:9f4107db1bff 37 distribute, sublicense, and/or sell copies of the Software, and to
umairaftab 38:9f4107db1bff 38 permit persons to whom the Software is furnished to do so, subject to
umairaftab 38:9f4107db1bff 39 the following conditions:
umairaftab 38:9f4107db1bff 40
umairaftab 38:9f4107db1bff 41 The above copyright notice and this permission notice shall be
umairaftab 38:9f4107db1bff 42 included in all copies or substantial portions of the Software.
umairaftab 38:9f4107db1bff 43
umairaftab 38:9f4107db1bff 44 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
umairaftab 38:9f4107db1bff 45 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
umairaftab 38:9f4107db1bff 46 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
umairaftab 38:9f4107db1bff 47 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
umairaftab 38:9f4107db1bff 48 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
umairaftab 38:9f4107db1bff 49 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
umairaftab 38:9f4107db1bff 50 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
umairaftab 38:9f4107db1bff 51
umairaftab 38:9f4107db1bff 52 Much of the code was inspired by Derek Yerger's code, though I don't
umairaftab 38:9f4107db1bff 53 think much of that remains. In any event that was..
umairaftab 38:9f4107db1bff 54 (copyleft) 2006 by Derek Yerger - Free to distribute freely.
umairaftab 38:9f4107db1bff 55
umairaftab 38:9f4107db1bff 56 The CRC code was excerpted and inspired by the Dallas Semiconductor
umairaftab 38:9f4107db1bff 57 sample code bearing this copyright.
umairaftab 38:9f4107db1bff 58 */
umairaftab 38:9f4107db1bff 59 //---------------------------------------------------------------------------
umairaftab 38:9f4107db1bff 60 // Copyright (C) 2000 Dallas Semiconductor Corporation, All Rights Reserved.
umairaftab 38:9f4107db1bff 61 //
umairaftab 38:9f4107db1bff 62 // Permission is hereby granted, free of charge, to any person obtaining a
umairaftab 38:9f4107db1bff 63 // copy of this software and associated documentation files (the "Software"),
umairaftab 38:9f4107db1bff 64 // to deal in the Software without restriction, including without limitation
umairaftab 38:9f4107db1bff 65 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
umairaftab 38:9f4107db1bff 66 // and/or sell copies of the Software, and to permit persons to whom the
umairaftab 38:9f4107db1bff 67 // Software is furnished to do so, subject to the following conditions:
umairaftab 38:9f4107db1bff 68 //
umairaftab 38:9f4107db1bff 69 // The above copyright notice and this permission notice shall be included
umairaftab 38:9f4107db1bff 70 // in all copies or substantial portions of the Software.
umairaftab 38:9f4107db1bff 71 //
umairaftab 38:9f4107db1bff 72 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
umairaftab 38:9f4107db1bff 73 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
umairaftab 38:9f4107db1bff 74 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
umairaftab 38:9f4107db1bff 75 // IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
umairaftab 38:9f4107db1bff 76 // OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
umairaftab 38:9f4107db1bff 77 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
umairaftab 38:9f4107db1bff 78 // OTHER DEALINGS IN THE SOFTWARE.
umairaftab 38:9f4107db1bff 79 //
umairaftab 38:9f4107db1bff 80 // Except as contained in this notice, the name of Dallas Semiconductor
umairaftab 38:9f4107db1bff 81 // shall not be used except as stated in the Dallas Semiconductor
umairaftab 38:9f4107db1bff 82 // Branding Policy.
umairaftab 38:9f4107db1bff 83 //--------------------------------------------------------------------------
umairaftab 38:9f4107db1bff 84
umairaftab 38:9f4107db1bff 85 #ifndef SNATCH59_ONEWIRECRC_H
umairaftab 38:9f4107db1bff 86 #define SNATCH59_ONEWIRECRC_H
umairaftab 38:9f4107db1bff 87
umairaftab 38:9f4107db1bff 88 #include <mbed.h>
umairaftab 38:9f4107db1bff 89
umairaftab 38:9f4107db1bff 90 // Select the table-lookup method of computing the 8-bit CRC by setting this to 1
umairaftab 38:9f4107db1bff 91 #ifndef ONEWIRE_CRC8_TABLE
umairaftab 38:9f4107db1bff 92 #define ONEWIRE_CRC8_TABLE 1
umairaftab 38:9f4107db1bff 93 #endif
umairaftab 38:9f4107db1bff 94
umairaftab 38:9f4107db1bff 95 typedef unsigned char BYTE; // used to be uint8_t : something a byte wide, whatever ....
umairaftab 38:9f4107db1bff 96
umairaftab 38:9f4107db1bff 97 enum eSpeed {OVERDRIVE, STANDARD};
umairaftab 38:9f4107db1bff 98
umairaftab 38:9f4107db1bff 99 class OneWireCRC
umairaftab 38:9f4107db1bff 100 {
umairaftab 38:9f4107db1bff 101 public:
umairaftab 38:9f4107db1bff 102 OneWireCRC(PinName oneWire, eSpeed);
umairaftab 38:9f4107db1bff 103
umairaftab 38:9f4107db1bff 104 // reset, read, write functions
umairaftab 38:9f4107db1bff 105 int reset();
umairaftab 38:9f4107db1bff 106 void writeByte(int data);
umairaftab 38:9f4107db1bff 107 int readByte();
umairaftab 38:9f4107db1bff 108 int touchByte(int data);
umairaftab 38:9f4107db1bff 109 void block(BYTE* data, int data_len);
umairaftab 38:9f4107db1bff 110 int overdriveSkip(BYTE* data, int data_len);
umairaftab 38:9f4107db1bff 111
umairaftab 38:9f4107db1bff 112 // address functions
umairaftab 38:9f4107db1bff 113 void matchROM(BYTE rom[8]);
umairaftab 38:9f4107db1bff 114 void skipROM();
umairaftab 38:9f4107db1bff 115
umairaftab 38:9f4107db1bff 116 // address search functions
umairaftab 38:9f4107db1bff 117 void resetSearch();
umairaftab 38:9f4107db1bff 118 BYTE search(BYTE* newAddr);
umairaftab 38:9f4107db1bff 119
umairaftab 38:9f4107db1bff 120 // CRC check functions
umairaftab 38:9f4107db1bff 121 static BYTE crc8(BYTE* addr, BYTE len);
umairaftab 38:9f4107db1bff 122 static unsigned short crc16(unsigned short* data, unsigned short len);
umairaftab 38:9f4107db1bff 123
umairaftab 38:9f4107db1bff 124 private:
umairaftab 38:9f4107db1bff 125 const int* timing;
umairaftab 38:9f4107db1bff 126
umairaftab 38:9f4107db1bff 127 BYTE address[8];
umairaftab 38:9f4107db1bff 128 int searchJunction; // so we can set to it -1 somewhere
umairaftab 38:9f4107db1bff 129 bool searchExhausted;
umairaftab 38:9f4107db1bff 130
umairaftab 38:9f4107db1bff 131 DigitalInOut oneWirePort;
umairaftab 38:9f4107db1bff 132
umairaftab 38:9f4107db1bff 133 // read/write bit functions
umairaftab 38:9f4107db1bff 134 void writeBit(int bit);
umairaftab 38:9f4107db1bff 135 int readBit();
umairaftab 38:9f4107db1bff 136 };
umairaftab 38:9f4107db1bff 137
umairaftab 38:9f4107db1bff 138 #endif