Code for the Hexiwear sensor system. Requires an Air Quality Click, Carbon Monoxide Click, and Buzzer Click for full functionality. Currently only reads values and displays to the OLED while testing and alerting the user of present threats. Future goals are to incorporate button presses with separate screens to display the data as well as using the KW40 drivers to transmit the data. Still in early stages of development, many unnecessary files will be removed and cleaned up once final product is completed within the next month. Driver.cpp is the main driver for the program and was written for purposes of this project. All other headers and functions were found on mbed.org from other developers repositories or provided by NXP Semiconductors for purposes of this project.

Dependencies:   Hexi_KW40Z images

Committer:
Gfolker
Date:
Fri Apr 28 07:26:16 2017 +0000
Revision:
3:24b332b8e41d
Parent:
0:f70b1d60f794
Final version of the project - BLE integrated, code cleaned up, ARC calculation implemented, all user interface screens/button presses implemented, alert states tested and verified

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Gfolker 0:f70b1d60f794 1 /** OLED Types
Gfolker 0:f70b1d60f794 2 * This file contains OLED-related data structures.
Gfolker 0:f70b1d60f794 3 *
Gfolker 0:f70b1d60f794 4 * Redistribution and use in source and binary forms, with or without modification,
Gfolker 0:f70b1d60f794 5 * are permitted provided that the following conditions are met:
Gfolker 0:f70b1d60f794 6 *
Gfolker 0:f70b1d60f794 7 * Redistributions of source code must retain the above copyright notice, this list
Gfolker 0:f70b1d60f794 8 * of conditions and the following disclaimer.
Gfolker 0:f70b1d60f794 9 *
Gfolker 0:f70b1d60f794 10 * Redistributions in binary form must reproduce the above copyright notice, this
Gfolker 0:f70b1d60f794 11 * list of conditions and the following disclaimer in the documentation and/or
Gfolker 0:f70b1d60f794 12 * other materials provided with the distribution.
Gfolker 0:f70b1d60f794 13 *
Gfolker 0:f70b1d60f794 14 * Neither the name of NXP, nor the names of its
Gfolker 0:f70b1d60f794 15 * contributors may be used to endorse or promote products derived from this
Gfolker 0:f70b1d60f794 16 * software without specific prior written permission.
Gfolker 0:f70b1d60f794 17 *
Gfolker 0:f70b1d60f794 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
Gfolker 0:f70b1d60f794 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
Gfolker 0:f70b1d60f794 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Gfolker 0:f70b1d60f794 21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
Gfolker 0:f70b1d60f794 22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Gfolker 0:f70b1d60f794 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
Gfolker 0:f70b1d60f794 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
Gfolker 0:f70b1d60f794 25 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Gfolker 0:f70b1d60f794 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Gfolker 0:f70b1d60f794 27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Gfolker 0:f70b1d60f794 28 *
Gfolker 0:f70b1d60f794 29 * visit: http://www.mikroe.com and http://www.nxp.com
Gfolker 0:f70b1d60f794 30 *
Gfolker 0:f70b1d60f794 31 * get support at: http://www.mikroe.com/forum and https://community.nxp.com
Gfolker 0:f70b1d60f794 32 *
Gfolker 0:f70b1d60f794 33 * Project HEXIWEAR, 2015
Gfolker 0:f70b1d60f794 34 */
Gfolker 0:f70b1d60f794 35
Gfolker 0:f70b1d60f794 36
Gfolker 0:f70b1d60f794 37 /**
Gfolker 0:f70b1d60f794 38 * OLED-related data structures
Gfolker 0:f70b1d60f794 39 * Project HEXIWEAR, 2015
Gfolker 0:f70b1d60f794 40 */
Gfolker 0:f70b1d60f794 41
Gfolker 0:f70b1d60f794 42 #ifndef HG_OLED_TYPES
Gfolker 0:f70b1d60f794 43 #define HG_OLED_TYPES
Gfolker 0:f70b1d60f794 44
Gfolker 0:f70b1d60f794 45 #include <stdint.h>
Gfolker 0:f70b1d60f794 46
Gfolker 0:f70b1d60f794 47 typedef enum
Gfolker 0:f70b1d60f794 48 {
Gfolker 0:f70b1d60f794 49 OLED_TRANSITION_NONE,
Gfolker 0:f70b1d60f794 50 OLED_TRANSITION_TOP_DOWN,
Gfolker 0:f70b1d60f794 51 OLED_TRANSITION_DOWN_TOP,
Gfolker 0:f70b1d60f794 52 OLED_TRANSITION_LEFT_RIGHT,
Gfolker 0:f70b1d60f794 53 OLED_TRANSITION_RIGHT_LEFT
Gfolker 0:f70b1d60f794 54
Gfolker 0:f70b1d60f794 55 } oled_transition_t;
Gfolker 0:f70b1d60f794 56
Gfolker 0:f70b1d60f794 57 typedef enum
Gfolker 0:f70b1d60f794 58 {
Gfolker 0:f70b1d60f794 59 OLED_STATUS_SUCCESS, // success
Gfolker 0:f70b1d60f794 60 OLED_STATUS_ERROR, // fail
Gfolker 0:f70b1d60f794 61 OLED_STATUS_PROTOCOL_ERROR, // SPI failure
Gfolker 0:f70b1d60f794 62 OLED_STATUS_INIT_ERROR, // initialization error
Gfolker 0:f70b1d60f794 63 OLED_STATUS_DEINIT_ERROR // deinitialization error
Gfolker 0:f70b1d60f794 64
Gfolker 0:f70b1d60f794 65 } oled_status_t;
Gfolker 0:f70b1d60f794 66
Gfolker 0:f70b1d60f794 67
Gfolker 0:f70b1d60f794 68 #if 0
Gfolker 0:f70b1d60f794 69 typedef struct
Gfolker 0:f70b1d60f794 70 {
Gfolker 0:f70b1d60f794 71 /**
Gfolker 0:f70b1d60f794 72 * SPI relevant information
Gfolker 0:f70b1d60f794 73 */
Gfolker 0:f70b1d60f794 74 genericSpiHandle_t protocol;
Gfolker 0:f70b1d60f794 75
Gfolker 0:f70b1d60f794 76 } handleOLED_t;
Gfolker 0:f70b1d60f794 77 #endif
Gfolker 0:f70b1d60f794 78
Gfolker 0:f70b1d60f794 79
Gfolker 0:f70b1d60f794 80 typedef uint16_t* oled_pixel_t;
Gfolker 0:f70b1d60f794 81
Gfolker 0:f70b1d60f794 82 typedef struct
Gfolker 0:f70b1d60f794 83 {
Gfolker 0:f70b1d60f794 84 uint32_t DCpin;
Gfolker 0:f70b1d60f794 85 uint32_t CSpin;
Gfolker 0:f70b1d60f794 86 uint32_t RSTpin;
Gfolker 0:f70b1d60f794 87 // uint32_t RWpin;
Gfolker 0:f70b1d60f794 88 uint32_t ENpin;
Gfolker 0:f70b1d60f794 89
Gfolker 0:f70b1d60f794 90 } settingsOLED_t;
Gfolker 0:f70b1d60f794 91
Gfolker 0:f70b1d60f794 92 typedef enum
Gfolker 0:f70b1d60f794 93 {
Gfolker 0:f70b1d60f794 94 OLED_TEXT_ALIGN_NONE = 0,
Gfolker 0:f70b1d60f794 95
Gfolker 0:f70b1d60f794 96 OLED_TEXT_ALIGN_LEFT = 0x1,
Gfolker 0:f70b1d60f794 97 OLED_TEXT_ALIGN_RIGHT = 0x2,
Gfolker 0:f70b1d60f794 98 OLED_TEXT_ALIGN_CENTER = 0x3,
Gfolker 0:f70b1d60f794 99
Gfolker 0:f70b1d60f794 100 OLED_TEXT_VALIGN_TOP = 0x10,
Gfolker 0:f70b1d60f794 101 OLED_TEXT_VALIGN_BOTTOM = 0x20,
Gfolker 0:f70b1d60f794 102 OLED_TEXT_VALIGN_CENTER = 0x30
Gfolker 0:f70b1d60f794 103
Gfolker 0:f70b1d60f794 104 } oled_text_align_t;
Gfolker 0:f70b1d60f794 105
Gfolker 0:f70b1d60f794 106 typedef struct
Gfolker 0:f70b1d60f794 107 {
Gfolker 0:f70b1d60f794 108 int8_t xCrd;
Gfolker 0:f70b1d60f794 109 int8_t yCrd;
Gfolker 0:f70b1d60f794 110 uint8_t width;
Gfolker 0:f70b1d60f794 111 uint8_t height;
Gfolker 0:f70b1d60f794 112 oled_pixel_t areaBuffer;
Gfolker 0:f70b1d60f794 113
Gfolker 0:f70b1d60f794 114 } oled_dynamic_area_t;
Gfolker 0:f70b1d60f794 115
Gfolker 0:f70b1d60f794 116 typedef struct
Gfolker 0:f70b1d60f794 117 {
Gfolker 0:f70b1d60f794 118 const uint8_t* font;
Gfolker 0:f70b1d60f794 119 uint16_t fontColor;
Gfolker 0:f70b1d60f794 120 oled_text_align_t alignParam;
Gfolker 0:f70b1d60f794 121 const uint8_t* background;
Gfolker 0:f70b1d60f794 122
Gfolker 0:f70b1d60f794 123 } oled_text_properties_t;
Gfolker 0:f70b1d60f794 124
Gfolker 0:f70b1d60f794 125
Gfolker 0:f70b1d60f794 126 /** color chart */
Gfolker 0:f70b1d60f794 127 typedef enum
Gfolker 0:f70b1d60f794 128 {
Gfolker 0:f70b1d60f794 129 COLOR_BLACK = 0x0000,
Gfolker 0:f70b1d60f794 130 COLOR_BLUE_1 = 0x06FF,
Gfolker 0:f70b1d60f794 131 COLOR_BLUE = 0x001F,
Gfolker 0:f70b1d60f794 132 COLOR_RED = 0xF800,
Gfolker 0:f70b1d60f794 133 COLOR_GREEN = 0x07E0,
Gfolker 0:f70b1d60f794 134 COLOR_CYAN = 0x07FF,
Gfolker 0:f70b1d60f794 135 COLOR_MAGENTA = 0xF81F,
Gfolker 0:f70b1d60f794 136 COLOR_YELLOW = 0xFFE0,
Gfolker 0:f70b1d60f794 137 COLOR_GRAY = 0x528A,
Gfolker 0:f70b1d60f794 138 COLOR_WHITE = 0xFFFF
Gfolker 0:f70b1d60f794 139
Gfolker 0:f70b1d60f794 140 } Color_t;
Gfolker 0:f70b1d60f794 141
Gfolker 0:f70b1d60f794 142 typedef struct _init_cmd_tag
Gfolker 0:f70b1d60f794 143 {
Gfolker 0:f70b1d60f794 144 uint32_t cmd;
Gfolker 0:f70b1d60f794 145 uint8_t type;
Gfolker 0:f70b1d60f794 146 } init_cmd_t;
Gfolker 0:f70b1d60f794 147
Gfolker 0:f70b1d60f794 148 #endif
Gfolker 0:f70b1d60f794 149