mirror of
https://github.com/firewalkwithm3/Sensor-Watch.git
synced 2024-11-22 19:20:30 +08:00
Activity face + Chirpy TX (#187)
* chirpy demo face; activity face stub * activity face WIP: can log, pause and clear * activity face and chirpy demo: ready to flash to watch * activity face tweaks * hour display for hours < 10 * fix: added rogue paused seconds when stopping activity * LE mode; lower power with 1Hz tick * fix: midnight is 12 * Documentation in code comments * fixes from code review by @neutralinsomniac * chirpy_demo_face option to chirp out nanosec.ini + auto-format * UI tweaks * remove erroneously added file (content revoked) * UI tweaks: return from LE mode; time display vs LAP * add default loop handler (will enable long-mode-to-first-face) * reset watch faces to match main branch
This commit is contained in:
parent
2d46a9bf9e
commit
9af51de624
179
movement/lib/chirpy_tx/chirpy_tx.c
Normal file
179
movement/lib/chirpy_tx/chirpy_tx.c
Normal file
|
@ -0,0 +1,179 @@
|
||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Gabor L Ugray
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "chirpy_tx.h"
|
||||||
|
|
||||||
|
static const uint32_t chirpy_min_freq = 2500;
|
||||||
|
static const uint32_t cirpy_freq_step = 250;
|
||||||
|
|
||||||
|
// This many bytes are followed by a CRC and block separator
|
||||||
|
// It's a multiple of 3 so no bits are wasted (a tone encodes 3 bits)
|
||||||
|
// Last block can be shorter
|
||||||
|
static const uint8_t chirpy_default_block_size = 15;
|
||||||
|
|
||||||
|
// The dedicated control tone. This is the highest tone index.
|
||||||
|
static const uint8_t chirpy_control_tone = 8;
|
||||||
|
|
||||||
|
// Pre-computed tone periods. This is allocated and populated on-demand.
|
||||||
|
static uint32_t *chirpy_tone_periods = NULL;
|
||||||
|
|
||||||
|
uint8_t chirpy_crc8(const uint8_t *addr, uint16_t len) {
|
||||||
|
uint8_t crc = 0;
|
||||||
|
for (uint16_t i = 0; i < len; i++)
|
||||||
|
crc = chirpy_update_crc8(addr[i], crc);
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t chirpy_update_crc8(uint8_t next_byte, uint8_t crc) {
|
||||||
|
for (uint8_t j = 0; j < 8; j++) {
|
||||||
|
uint8_t mix = (crc ^ next_byte) & 0x01;
|
||||||
|
crc >>= 1;
|
||||||
|
if (mix)
|
||||||
|
crc ^= 0x8C;
|
||||||
|
next_byte >>= 1;
|
||||||
|
}
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _chirpy_append_tone(chirpy_encoder_state_t *ces, uint8_t tone) {
|
||||||
|
// This is BAD and should never happen. But if it does, we'd rather
|
||||||
|
// create a corrupt transmission than corrupt memory #$^@
|
||||||
|
if (ces->tone_count == CHIRPY_TONE_BUF_SIZE)
|
||||||
|
return;
|
||||||
|
ces->tone_buf[ces->tone_count] = tone;
|
||||||
|
++ces->tone_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
void chirpy_init_encoder(chirpy_encoder_state_t *ces, chirpy_get_next_byte_t get_next_byte) {
|
||||||
|
memset(ces, 0, sizeof(chirpy_encoder_state_t));
|
||||||
|
ces->block_size = chirpy_default_block_size;
|
||||||
|
ces->get_next_byte = get_next_byte;
|
||||||
|
_chirpy_append_tone(ces, 8);
|
||||||
|
_chirpy_append_tone(ces, 0);
|
||||||
|
_chirpy_append_tone(ces, 8);
|
||||||
|
_chirpy_append_tone(ces, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t _chirpy_retrieve_next_tone(chirpy_encoder_state_t *ces) {
|
||||||
|
if (ces->tone_pos == ces->tone_count)
|
||||||
|
return 255;
|
||||||
|
|
||||||
|
uint8_t res = ces->tone_buf[ces->tone_pos];
|
||||||
|
++ces->tone_pos;
|
||||||
|
if (ces->tone_pos == ces->tone_count) {
|
||||||
|
// End of buffer: reset buffer
|
||||||
|
ces->tone_pos = 0;
|
||||||
|
ces->tone_count = 0;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _chirpy_encode_bits(chirpy_encoder_state_t *ces, uint8_t force_partial) {
|
||||||
|
while (ces->bit_count > 0) {
|
||||||
|
if (ces->bit_count < 3 && !force_partial) break;
|
||||||
|
uint8_t tone = (uint8_t)(ces->bits >> 13);
|
||||||
|
_chirpy_append_tone(ces, tone);
|
||||||
|
if (ces->bit_count >= 3) {
|
||||||
|
ces->bits <<= 3;
|
||||||
|
ces->bit_count -= 3;
|
||||||
|
} else {
|
||||||
|
ces->bits = 0;
|
||||||
|
ces->bit_count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _chirpy_finish_block(chirpy_encoder_state_t *ces) {
|
||||||
|
_chirpy_append_tone(ces, chirpy_control_tone);
|
||||||
|
ces->bits = ces->crc;
|
||||||
|
ces->bits <<= 8;
|
||||||
|
ces->bit_count = 8;
|
||||||
|
_chirpy_encode_bits(ces, 1);
|
||||||
|
ces->bit_count = 0;
|
||||||
|
ces->crc = 0;
|
||||||
|
ces->block_len = 0;
|
||||||
|
_chirpy_append_tone(ces, chirpy_control_tone);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _chirpy_finish_transmission(chirpy_encoder_state_t *ces) {
|
||||||
|
_chirpy_append_tone(ces, chirpy_control_tone);
|
||||||
|
_chirpy_append_tone(ces, chirpy_control_tone);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t chirpy_get_next_tone(chirpy_encoder_state_t *ces) {
|
||||||
|
// If there are tones left in the buffer, keep sending those
|
||||||
|
if (ces->tone_pos < ces->tone_count)
|
||||||
|
return _chirpy_retrieve_next_tone(ces);
|
||||||
|
|
||||||
|
// We know data is over: that means we've wrapped up transmission
|
||||||
|
// Just drain tone buffer, and then keep sendig EOB
|
||||||
|
if (ces->get_next_byte == 0)
|
||||||
|
return _chirpy_retrieve_next_tone(ces);
|
||||||
|
|
||||||
|
// Fetch next byte
|
||||||
|
uint8_t next_byte;
|
||||||
|
uint8_t got_more = ces->get_next_byte(&next_byte);
|
||||||
|
|
||||||
|
// Data over: write CRC if we sent a partial buffer; send end signal
|
||||||
|
if (got_more == 0) {
|
||||||
|
ces->get_next_byte = 0;
|
||||||
|
if (ces->bit_count > 0) _chirpy_encode_bits(ces, 1);
|
||||||
|
if (ces->block_len > 0) _chirpy_finish_block(ces);
|
||||||
|
_chirpy_finish_transmission(ces);
|
||||||
|
return _chirpy_retrieve_next_tone(ces);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Got more data: add to bits; convert
|
||||||
|
uint16_t msk = next_byte;
|
||||||
|
msk <<= (8 - ces->bit_count);
|
||||||
|
ces->bits |= msk;
|
||||||
|
ces->bit_count += 8;
|
||||||
|
_chirpy_encode_bits(ces, 0);
|
||||||
|
++ces->block_len;
|
||||||
|
ces->crc = chirpy_update_crc8(next_byte, ces->crc);
|
||||||
|
if (ces->block_len == ces->block_size)
|
||||||
|
_chirpy_finish_block(ces);
|
||||||
|
|
||||||
|
return _chirpy_retrieve_next_tone(ces);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t chirpy_get_tone_period(uint8_t tone) {
|
||||||
|
// Create pre-computed tone periods array on first use
|
||||||
|
if (chirpy_tone_periods == NULL) {
|
||||||
|
chirpy_tone_periods = malloc((chirpy_control_tone + 1) * sizeof(uint32_t));
|
||||||
|
for (uint8_t i = 0; i < chirpy_control_tone + 1; ++i) {
|
||||||
|
uint32_t freq = chirpy_min_freq + i * cirpy_freq_step;
|
||||||
|
uint16_t period = 1000000 / freq;
|
||||||
|
chirpy_tone_periods[i] = period;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Return pre-computed value, but be paranoid about indexing into array
|
||||||
|
if (tone > chirpy_control_tone)
|
||||||
|
tone = chirpy_control_tone;
|
||||||
|
return chirpy_tone_periods[tone];
|
||||||
|
}
|
98
movement/lib/chirpy_tx/chirpy_tx.h
Normal file
98
movement/lib/chirpy_tx/chirpy_tx.h
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Gabor L Ugray
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CHIRPY_TX_H
|
||||||
|
#define CHIRPY_TX_H
|
||||||
|
|
||||||
|
/** @brief Calculates the CRC of a byte sequence.
|
||||||
|
*/
|
||||||
|
uint8_t chirpy_crc8(const uint8_t *addr, uint16_t len);
|
||||||
|
|
||||||
|
/** @brief Updates a CRC value with the next byte of input.
|
||||||
|
*/
|
||||||
|
uint8_t chirpy_update_crc8(uint8_t next_byte, uint8_t crc);
|
||||||
|
|
||||||
|
/** @brief Function to return next byte to be encoded.
|
||||||
|
* @param next_byte Pointer where implementor must write next byte (if available).
|
||||||
|
* @return 1 if there is a next byte, or 0 if no more data to encode.
|
||||||
|
*/
|
||||||
|
typedef uint8_t (*chirpy_get_next_byte_t)(uint8_t *next_byte);
|
||||||
|
|
||||||
|
#define CHIRPY_TONE_BUF_SIZE 16
|
||||||
|
|
||||||
|
// Holds state used by the encoder. Do not manipulate directly.
|
||||||
|
typedef struct {
|
||||||
|
uint8_t tone_buf[CHIRPY_TONE_BUF_SIZE];
|
||||||
|
uint8_t tone_pos;
|
||||||
|
uint8_t tone_count;
|
||||||
|
uint8_t block_len;
|
||||||
|
uint8_t block_size;
|
||||||
|
uint8_t crc;
|
||||||
|
uint16_t bits;
|
||||||
|
uint8_t bit_count;
|
||||||
|
chirpy_get_next_byte_t get_next_byte;
|
||||||
|
} chirpy_encoder_state_t;
|
||||||
|
|
||||||
|
/** @brief Iniitializes the encoder state to be used during the transmission.
|
||||||
|
* @param ces Pointer to encoder state object to be initialized.
|
||||||
|
* @param get_next_byte Pointer to function that the encoder will call to fetch data byte by byte.
|
||||||
|
*/
|
||||||
|
void chirpy_init_encoder(chirpy_encoder_state_t *ces, chirpy_get_next_byte_t get_next_byte);
|
||||||
|
|
||||||
|
/** @brief Returns the next tone to be transmitted.
|
||||||
|
* @details This function will call the get_next_byte function stored in the encoder state to
|
||||||
|
* retrieve the next byte to be transmitted as needed. As a single byte is encoded as several tones,
|
||||||
|
* and because the transmission also includes periodic CRC values, not every call to this function
|
||||||
|
* will result in a callback for the next data byte.
|
||||||
|
* @param ced Pointer to the encoder state object.
|
||||||
|
* @return A tone index from 0 to N (where N is the largest tone index), or 255 if the transmission is over.
|
||||||
|
*/
|
||||||
|
uint8_t chirpy_get_next_tone(chirpy_encoder_state_t *ces);
|
||||||
|
|
||||||
|
/** @brief Returns the period value for buzzing out a tone.
|
||||||
|
* @param tone The tone index, 0 thru 8.
|
||||||
|
* @return The period for the tone's frequency, i.e., 1_000_000 / freq.
|
||||||
|
*/
|
||||||
|
uint16_t chirpy_get_tone_period(uint8_t tone);
|
||||||
|
|
||||||
|
/** @brief Typedef for a tick handler function.
|
||||||
|
*/
|
||||||
|
typedef void (*chirpy_tick_fun_t)(void *context);
|
||||||
|
|
||||||
|
/** @brief Creature-comfort struct for use in your chirping code.
|
||||||
|
* @details The idea is to handle a tick that happens 64 times per second at the outermost level.
|
||||||
|
* To get to the desired ~20 tones per second, increment a counter and call the actual
|
||||||
|
* transmission ticker when tick_counter reaches tick_compare, with a compare value of 3.
|
||||||
|
* seq_pos is for use by the transmission function to keep track of where it is in the data.
|
||||||
|
* The current transmission function is stored in tick_fun. You can have multiple phases
|
||||||
|
* by switching to a different function. E.g., intro countdown first, followed by data chirping.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
uint8_t tick_count;
|
||||||
|
uint8_t tick_compare;
|
||||||
|
uint16_t seq_pos;
|
||||||
|
chirpy_tick_fun_t tick_fun;
|
||||||
|
} chirpy_tick_state_t;
|
||||||
|
|
||||||
|
#endif
|
160
movement/lib/chirpy_tx/test/test_main.c
Normal file
160
movement/lib/chirpy_tx/test/test_main.c
Normal file
|
@ -0,0 +1,160 @@
|
||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Gabor L Ugray
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "../src/lib/chirpy_tx.h"
|
||||||
|
#include "unity.h"
|
||||||
|
|
||||||
|
|
||||||
|
void setUp(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void tearDown(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *crc_test_str0 = "";
|
||||||
|
const char *crc_test_str1 = "h";
|
||||||
|
const char *crc_test_str2 = "he";
|
||||||
|
const char *crc_test_str3 = "hen";
|
||||||
|
const char *crc_test_str4 = "henl";
|
||||||
|
const char *crc_test_str5 = "henlO";
|
||||||
|
|
||||||
|
#define CRC_VAL_COUNT 5
|
||||||
|
const uint8_t crc_vals[] = {167, 118, 95, 92, 127};
|
||||||
|
|
||||||
|
void test_crc8() {
|
||||||
|
TEST_ASSERT_EQUAL_UINT8(0, chirpy_crc8((const uint8_t *)crc_test_str0, 0));
|
||||||
|
TEST_ASSERT_EQUAL_UINT8(167, chirpy_crc8((const uint8_t *)crc_test_str1, strlen(crc_test_str1)));
|
||||||
|
TEST_ASSERT_EQUAL_UINT8(118, chirpy_crc8((const uint8_t *)crc_test_str2, strlen(crc_test_str2)));
|
||||||
|
TEST_ASSERT_EQUAL_UINT8(95, chirpy_crc8((const uint8_t *)crc_test_str3, strlen(crc_test_str3)));
|
||||||
|
TEST_ASSERT_EQUAL_UINT8(92, chirpy_crc8((const uint8_t *)crc_test_str4, strlen(crc_test_str4)));
|
||||||
|
TEST_ASSERT_EQUAL_UINT8(127, chirpy_crc8((const uint8_t *)crc_test_str5, strlen(crc_test_str5)));
|
||||||
|
|
||||||
|
uint8_t crc = 0;
|
||||||
|
for (uint16_t i = 0; i < CRC_VAL_COUNT; ++i) {
|
||||||
|
uint8_t next_byte = crc_test_str5[i];
|
||||||
|
crc = chirpy_update_crc8(next_byte, crc);
|
||||||
|
TEST_ASSERT_EQUAL_UINT8(crc_vals[i], crc);
|
||||||
|
}
|
||||||
|
|
||||||
|
crc = chirpy_update_crc8(0, 0);
|
||||||
|
TEST_ASSERT_EQUAL(0, crc);
|
||||||
|
|
||||||
|
crc = chirpy_update_crc8(0x4f, 0);
|
||||||
|
TEST_ASSERT_EQUAL(7, crc);
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint16_t data_len_01 = 0;
|
||||||
|
const uint8_t data_01[] = {};
|
||||||
|
const uint16_t tones_len_01 = 6;
|
||||||
|
const uint8_t tones_01[] = {8, 0, 8, 0, 8, 8};
|
||||||
|
|
||||||
|
const uint16_t data_len_02 = 1;
|
||||||
|
const uint8_t data_02[] = {0};
|
||||||
|
const uint16_t tones_len_02 = 14;
|
||||||
|
const uint8_t tones_02[] = {8, 0, 8, 0, 0, 0, 0, 8, 0, 0, 0, 8, 8, 8};
|
||||||
|
|
||||||
|
const uint16_t data_len_03 = 1;
|
||||||
|
const uint8_t data_03[] = {0x68};
|
||||||
|
const uint16_t tones_len_03 = 14;
|
||||||
|
const uint8_t tones_03[] = {8, 0, 8, 0, 3, 2, 0, 8, 5, 1, 6, 8, 8, 8};
|
||||||
|
|
||||||
|
const uint16_t data_len_04 = 3;
|
||||||
|
const uint8_t data_04[] = {0x68, 0x65, 0x6e};
|
||||||
|
const uint16_t tones_len_04 = 19;
|
||||||
|
const uint8_t tones_04[] = {8, 0, 8, 0, 3, 2, 0, 6, 2, 5, 5, 6, 8, 2, 7, 6, 8, 8, 8};
|
||||||
|
|
||||||
|
const uint16_t data_len_05 = 4;
|
||||||
|
const uint8_t data_05[] = {0x68, 0x65, 0x6e, 0x4f};
|
||||||
|
const uint16_t tones_len_05 = 27;
|
||||||
|
const uint8_t tones_05[] = {
|
||||||
|
8, 0, 8, 0, 3, 2, 0, 6, 2, 5, 5, 6, 8, 2, 7, 6, 8,
|
||||||
|
2, 3, 6, 8, 0, 1, 6, 8, 8, 8};
|
||||||
|
|
||||||
|
uint8_t curr_data_pos;
|
||||||
|
uint8_t curr_data_len;
|
||||||
|
const uint8_t *curr_data;
|
||||||
|
|
||||||
|
uint8_t get_next_byte(uint8_t *next_byte) {
|
||||||
|
if (curr_data_pos < curr_data_len) {
|
||||||
|
*next_byte = curr_data[curr_data_pos];
|
||||||
|
++curr_data_pos;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_encoder_one(const uint8_t *data, uint16_t data_len, const uint8_t *tones, uint16_t tones_len) {
|
||||||
|
curr_data = data;
|
||||||
|
curr_data_len = data_len;
|
||||||
|
curr_data_pos = 0;
|
||||||
|
chirpy_encoder_state_t ces;
|
||||||
|
chirpy_init_encoder(&ces, get_next_byte);
|
||||||
|
ces.block_size = 3;
|
||||||
|
|
||||||
|
uint8_t got_tones[2048] = {0};
|
||||||
|
uint16_t got_tone_pos = 0;
|
||||||
|
while (got_tone_pos < 2048) {
|
||||||
|
uint8_t tone = chirpy_get_next_tone(&ces);
|
||||||
|
got_tones[got_tone_pos] = tone;
|
||||||
|
if (tone == 255) break;
|
||||||
|
++got_tone_pos;
|
||||||
|
}
|
||||||
|
char buf1[65536];
|
||||||
|
char bufx[256];
|
||||||
|
memset(buf1, 0, 65536);
|
||||||
|
for (uint16_t i = 0; i < got_tone_pos; ++i) {
|
||||||
|
if (i == 0)
|
||||||
|
sprintf(bufx, "%d", got_tones[i]);
|
||||||
|
else
|
||||||
|
sprintf(bufx, ", %d", got_tones[i]);
|
||||||
|
strcat(buf1, bufx);
|
||||||
|
}
|
||||||
|
TEST_MESSAGE(buf1);
|
||||||
|
TEST_ASSERT_EQUAL(tones_len, got_tone_pos);
|
||||||
|
uint16_t smaller_len = tones_len < got_tone_pos ? tones_len : got_tone_pos;
|
||||||
|
TEST_ASSERT_EQUAL_UINT8_ARRAY(tones, got_tones, smaller_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_encoder() {
|
||||||
|
TEST_MESSAGE("Testing encoder with dataset 01");
|
||||||
|
test_encoder_one(data_01, data_len_01, tones_01, tones_len_01);
|
||||||
|
TEST_MESSAGE("Testing encoder with dataset 02");
|
||||||
|
test_encoder_one(data_02, data_len_02, tones_02, tones_len_02);
|
||||||
|
TEST_MESSAGE("Testing encoder with dataset 03");
|
||||||
|
test_encoder_one(data_03, data_len_03, tones_03, tones_len_03);
|
||||||
|
TEST_MESSAGE("Testing encoder with dataset 04");
|
||||||
|
test_encoder_one(data_04, data_len_04, tones_04, tones_len_04);
|
||||||
|
TEST_MESSAGE("Testing encoder with dataset 05");
|
||||||
|
test_encoder_one(data_05, data_len_05, tones_05, tones_len_05);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
UNITY_BEGIN();
|
||||||
|
RUN_TEST(test_crc8);
|
||||||
|
RUN_TEST(test_encoder);
|
||||||
|
return UNITY_END();
|
||||||
|
}
|
2466
movement/lib/chirpy_tx/test/unity.c
Normal file
2466
movement/lib/chirpy_tx/test/unity.c
Normal file
File diff suppressed because it is too large
Load diff
687
movement/lib/chirpy_tx/test/unity.h
Normal file
687
movement/lib/chirpy_tx/test/unity.h
Normal file
|
@ -0,0 +1,687 @@
|
||||||
|
/* ==========================================
|
||||||
|
Unity Project - A Test Framework for C
|
||||||
|
Copyright (c) 2007-21 Mike Karlesky, Mark VanderVoord, Greg Williams
|
||||||
|
[Released under MIT License. Please refer to license.txt for details]
|
||||||
|
========================================== */
|
||||||
|
|
||||||
|
#ifndef UNITY_FRAMEWORK_H
|
||||||
|
#define UNITY_FRAMEWORK_H
|
||||||
|
#define UNITY
|
||||||
|
|
||||||
|
#define UNITY_VERSION_MAJOR 2
|
||||||
|
#define UNITY_VERSION_MINOR 5
|
||||||
|
#define UNITY_VERSION_BUILD 4
|
||||||
|
#define UNITY_VERSION ((UNITY_VERSION_MAJOR << 16) | (UNITY_VERSION_MINOR << 8) | UNITY_VERSION_BUILD)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "unity_internals.h"
|
||||||
|
|
||||||
|
/*-------------------------------------------------------
|
||||||
|
* Test Setup / Teardown
|
||||||
|
*-------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* These functions are intended to be called before and after each test.
|
||||||
|
* If using unity directly, these will need to be provided for each test
|
||||||
|
* executable built. If you are using the test runner generator and/or
|
||||||
|
* Ceedling, these are optional. */
|
||||||
|
void setUp(void);
|
||||||
|
void tearDown(void);
|
||||||
|
|
||||||
|
/* These functions are intended to be called at the beginning and end of an
|
||||||
|
* entire test suite. suiteTearDown() is passed the number of tests that
|
||||||
|
* failed, and its return value becomes the exit code of main(). If using
|
||||||
|
* Unity directly, you're in charge of calling these if they are desired.
|
||||||
|
* If using Ceedling or the test runner generator, these will be called
|
||||||
|
* automatically if they exist. */
|
||||||
|
void suiteSetUp(void);
|
||||||
|
int suiteTearDown(int num_failures);
|
||||||
|
|
||||||
|
/*-------------------------------------------------------
|
||||||
|
* Test Reset and Verify
|
||||||
|
*-------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* These functions are intended to be called before during tests in order
|
||||||
|
* to support complex test loops, etc. Both are NOT built into Unity. Instead
|
||||||
|
* the test runner generator will create them. resetTest will run teardown and
|
||||||
|
* setup again, verifying any end-of-test needs between. verifyTest will only
|
||||||
|
* run the verification. */
|
||||||
|
void resetTest(void);
|
||||||
|
void verifyTest(void);
|
||||||
|
|
||||||
|
/*-------------------------------------------------------
|
||||||
|
* Configuration Options
|
||||||
|
*-------------------------------------------------------
|
||||||
|
* All options described below should be passed as a compiler flag to all files using Unity. If you must add #defines, place them BEFORE the #include above.
|
||||||
|
|
||||||
|
* Integers/longs/pointers
|
||||||
|
* - Unity attempts to automatically discover your integer sizes
|
||||||
|
* - define UNITY_EXCLUDE_STDINT_H to stop attempting to look in <stdint.h>
|
||||||
|
* - define UNITY_EXCLUDE_LIMITS_H to stop attempting to look in <limits.h>
|
||||||
|
* - If you cannot use the automatic methods above, you can force Unity by using these options:
|
||||||
|
* - define UNITY_SUPPORT_64
|
||||||
|
* - set UNITY_INT_WIDTH
|
||||||
|
* - set UNITY_LONG_WIDTH
|
||||||
|
* - set UNITY_POINTER_WIDTH
|
||||||
|
|
||||||
|
* Floats
|
||||||
|
* - define UNITY_EXCLUDE_FLOAT to disallow floating point comparisons
|
||||||
|
* - define UNITY_FLOAT_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_FLOAT
|
||||||
|
* - define UNITY_FLOAT_TYPE to specify doubles instead of single precision floats
|
||||||
|
* - define UNITY_INCLUDE_DOUBLE to allow double floating point comparisons
|
||||||
|
* - define UNITY_EXCLUDE_DOUBLE to disallow double floating point comparisons (default)
|
||||||
|
* - define UNITY_DOUBLE_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_DOUBLE
|
||||||
|
* - define UNITY_DOUBLE_TYPE to specify something other than double
|
||||||
|
* - define UNITY_EXCLUDE_FLOAT_PRINT to trim binary size, won't print floating point values in errors
|
||||||
|
|
||||||
|
* Output
|
||||||
|
* - by default, Unity prints to standard out with putchar. define UNITY_OUTPUT_CHAR(a) with a different function if desired
|
||||||
|
* - define UNITY_DIFFERENTIATE_FINAL_FAIL to print FAILED (vs. FAIL) at test end summary - for automated search for failure
|
||||||
|
|
||||||
|
* Optimization
|
||||||
|
* - by default, line numbers are stored in unsigned shorts. Define UNITY_LINE_TYPE with a different type if your files are huge
|
||||||
|
* - by default, test and failure counters are unsigned shorts. Define UNITY_COUNTER_TYPE with a different type if you want to save space or have more than 65535 Tests.
|
||||||
|
|
||||||
|
* Test Cases
|
||||||
|
* - define UNITY_SUPPORT_TEST_CASES to include the TEST_CASE macro, though really it's mostly about the runner generator script
|
||||||
|
|
||||||
|
* Parameterized Tests
|
||||||
|
* - you'll want to create a define of TEST_CASE(...) and/or TEST_RANGE(...) which basically evaluates to nothing
|
||||||
|
|
||||||
|
* Tests with Arguments
|
||||||
|
* - you'll want to define UNITY_USE_COMMAND_LINE_ARGS if you have the test runner passing arguments to Unity
|
||||||
|
|
||||||
|
*-------------------------------------------------------
|
||||||
|
* Basic Fail and Ignore
|
||||||
|
*-------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define TEST_FAIL_MESSAGE(message) UNITY_TEST_FAIL(__LINE__, (message))
|
||||||
|
#define TEST_FAIL() UNITY_TEST_FAIL(__LINE__, NULL)
|
||||||
|
#define TEST_IGNORE_MESSAGE(message) UNITY_TEST_IGNORE(__LINE__, (message))
|
||||||
|
#define TEST_IGNORE() UNITY_TEST_IGNORE(__LINE__, NULL)
|
||||||
|
#define TEST_MESSAGE(message) UnityMessage((message), __LINE__)
|
||||||
|
#define TEST_ONLY()
|
||||||
|
#ifdef UNITY_INCLUDE_PRINT_FORMATTED
|
||||||
|
#define TEST_PRINTF(message, ...) UnityPrintF(__LINE__, (message), __VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails.
|
||||||
|
* This method allows you to abort a test immediately with a PASS state, ignoring the remainder of the test. */
|
||||||
|
#define TEST_PASS() TEST_ABORT()
|
||||||
|
#define TEST_PASS_MESSAGE(message) do { UnityMessage((message), __LINE__); TEST_ABORT(); } while (0)
|
||||||
|
|
||||||
|
/* This macro does nothing, but it is useful for build tools (like Ceedling) to make use of this to figure out
|
||||||
|
* which files should be linked to in order to perform a test. Use it like TEST_FILE("sandwiches.c") */
|
||||||
|
#define TEST_FILE(a)
|
||||||
|
|
||||||
|
/*-------------------------------------------------------
|
||||||
|
* Test Asserts (simple)
|
||||||
|
*-------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Boolean */
|
||||||
|
#define TEST_ASSERT(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expression Evaluated To FALSE")
|
||||||
|
#define TEST_ASSERT_TRUE(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expected TRUE Was FALSE")
|
||||||
|
#define TEST_ASSERT_UNLESS(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expression Evaluated To TRUE")
|
||||||
|
#define TEST_ASSERT_FALSE(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expected FALSE Was TRUE")
|
||||||
|
#define TEST_ASSERT_NULL(pointer) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, " Expected NULL")
|
||||||
|
#define TEST_ASSERT_NOT_NULL(pointer) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, " Expected Non-NULL")
|
||||||
|
#define TEST_ASSERT_EMPTY(pointer) UNITY_TEST_ASSERT_EMPTY( (pointer), __LINE__, " Expected Empty")
|
||||||
|
#define TEST_ASSERT_NOT_EMPTY(pointer) UNITY_TEST_ASSERT_NOT_EMPTY((pointer), __LINE__, " Expected Non-Empty")
|
||||||
|
|
||||||
|
/* Integers (of all sizes) */
|
||||||
|
#define TEST_ASSERT_EQUAL_INT(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_INT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT8((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_INT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_INT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_INT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_size_t(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX8(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX16(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX32(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX64(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_CHAR(expected, actual) UNITY_TEST_ASSERT_EQUAL_CHAR((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_BITS(mask, expected, actual) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_BITS_HIGH(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT)(-1), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_BITS_LOW(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT)(0), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT)1 << (bit)), (UNITY_UINT)(-1), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT)1 << (bit)), (UNITY_UINT)(0), (actual), __LINE__, NULL)
|
||||||
|
|
||||||
|
/* Integer Not Equal To (of all sizes) */
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT8((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT16((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT32((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_INT64((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT8((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT16((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT32((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT64((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX8((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX16((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX32((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_HEX64((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_NOT_EQUAL_CHAR((threshold), (actual), __LINE__, NULL)
|
||||||
|
|
||||||
|
/* Integer Greater Than/ Less Than (of all sizes) */
|
||||||
|
#define TEST_ASSERT_GREATER_THAN(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT64((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_size_t(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_CHAR(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_CHAR((threshold), (actual), __LINE__, NULL)
|
||||||
|
|
||||||
|
#define TEST_ASSERT_LESS_THAN(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT64((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_size_t(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_CHAR(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_CHAR((threshold), (actual), __LINE__, NULL)
|
||||||
|
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, NULL)
|
||||||
|
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_size_t(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_CHAR(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, NULL)
|
||||||
|
|
||||||
|
/* Integer Ranges (of all sizes) */
|
||||||
|
#define TEST_ASSERT_INT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_INT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT8_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_INT16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT16_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_INT32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT32_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_INT64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT64_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_UINT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_UINT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT8_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_UINT16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT16_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_UINT32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT32_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_UINT64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT64_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_size_t_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_HEX_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_HEX8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX8_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_HEX16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX16_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_HEX32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_HEX64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_CHAR_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_CHAR_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
|
||||||
|
/* Integer Array Ranges (of all sizes) */
|
||||||
|
#define TEST_ASSERT_INT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_INT8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_INT16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_INT32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_INT64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_UINT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_UINT8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_UINT16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_UINT32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_UINT64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_size_t_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_HEX_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_HEX8_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_HEX16_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_HEX32_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_HEX64_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_CHAR_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, NULL)
|
||||||
|
|
||||||
|
|
||||||
|
/* Structs and Strings */
|
||||||
|
#define TEST_ASSERT_EQUAL_PTR(expected, actual) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_STRING(expected, actual) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len) UNITY_TEST_ASSERT_EQUAL_STRING_LEN((expected), (actual), (len), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_MEMORY(expected, actual, len) UNITY_TEST_ASSERT_EQUAL_MEMORY((expected), (actual), (len), __LINE__, NULL)
|
||||||
|
|
||||||
|
/* Arrays */
|
||||||
|
#define TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_size_t_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_CHAR_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_CHAR_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
|
||||||
|
/* Arrays Compared To Single Value */
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_INT16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT16((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT32((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT64((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_UINT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_UINT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT8((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_size_t(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_HEX(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_HEX32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX64((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_STRING(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_MEMORY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_CHAR(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_CHAR((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
|
||||||
|
/* Floating Point (If Enabled) */
|
||||||
|
#define TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_FLOAT_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_FLOAT_NOT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_FLOAT_NOT_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_FLOAT(expected, actual) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_FLOAT(expected, actual) UNITY_TEST_ASSERT_NOT_EQUAL_FLOAT((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_FLOAT_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_FLOAT_ARRAY_WITHIN((delta), (expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_FLOAT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_FLOAT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_FLOAT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_FLOAT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_FLOAT(threshold, actual) UNITY_TEST_ASSERT_LESS_THAN_FLOAT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_FLOAT(threshold, actual) UNITY_TEST_ASSERT_LESS_OR_EQUAL_FLOAT((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_FLOAT_IS_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_INF((actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_FLOAT_IS_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF((actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_FLOAT_IS_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NAN((actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_FLOAT_IS_DETERMINATE(actual) UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE((actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_FLOAT_IS_NOT_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF((actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF((actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_FLOAT_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN((actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE((actual), __LINE__, NULL)
|
||||||
|
|
||||||
|
/* Double (If Enabled) */
|
||||||
|
#define TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_DOUBLE_NOT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_DOUBLE_NOT_WITHIN((delta), (expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_DOUBLE(expected, actual) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_DOUBLE(expected, actual) UNITY_TEST_ASSERT_NOT_EQUAL_DOUBLE((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_DOUBLE_ARRAY_WITHIN(delta, expected, actual, num_elements) UNITY_TEST_ASSERT_DOUBLE_ARRAY_WITHIN((delta), (expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_THAN_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_LESS_THAN_DOUBLE((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_DOUBLE(threshold, actual) UNITY_TEST_ASSERT_LESS_OR_EQUAL_DOUBLE((threshold), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_DOUBLE_IS_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_INF((actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_DOUBLE_IS_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF((actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_DOUBLE_IS_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NAN((actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE((actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_DOUBLE_IS_NOT_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF((actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF((actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN((actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, NULL)
|
||||||
|
|
||||||
|
/* Shorthand */
|
||||||
|
#ifdef UNITY_SHORTHAND_AS_OLD
|
||||||
|
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal")
|
||||||
|
#endif
|
||||||
|
#ifdef UNITY_SHORTHAND_AS_INT
|
||||||
|
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
||||||
|
#endif
|
||||||
|
#ifdef UNITY_SHORTHAND_AS_MEM
|
||||||
|
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_MEMORY((&expected), (&actual), sizeof(expected), __LINE__, NULL)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
||||||
|
#endif
|
||||||
|
#ifdef UNITY_SHORTHAND_AS_RAW
|
||||||
|
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) == (actual)), __LINE__, " Expected Equal")
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal")
|
||||||
|
#endif
|
||||||
|
#ifdef UNITY_SHORTHAND_AS_NONE
|
||||||
|
#define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*-------------------------------------------------------
|
||||||
|
* Test Asserts (with additional messages)
|
||||||
|
*-------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Boolean */
|
||||||
|
#define TEST_ASSERT_MESSAGE(condition, message) UNITY_TEST_ASSERT( (condition), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_TRUE_MESSAGE(condition, message) UNITY_TEST_ASSERT( (condition), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_UNLESS_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_FALSE_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EMPTY_MESSAGE(pointer, message) UNITY_TEST_ASSERT_EMPTY( (pointer), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EMPTY_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NOT_EMPTY((pointer), __LINE__, (message))
|
||||||
|
|
||||||
|
/* Integers (of all sizes) */
|
||||||
|
#define TEST_ASSERT_EQUAL_INT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_INT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT8((expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_INT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_INT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_INT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_size_t_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_BITS_MESSAGE(mask, expected, actual, message) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_BITS_HIGH_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(-1), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_BITS_LOW_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(0), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_BIT_HIGH_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_BIT_LOW_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_CHAR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_CHAR((expected), (actual), __LINE__, (message))
|
||||||
|
|
||||||
|
/* Integer Not Equal To (of all sizes) */
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT8((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT16((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT32((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_INT64((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT8((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT16((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT32((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT64((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX8((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX16((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX32((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_HEX64((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_CHAR((threshold), (actual), __LINE__, (message))
|
||||||
|
|
||||||
|
|
||||||
|
/* Integer Greater Than/ Less Than (of all sizes) */
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT64((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_CHAR((threshold), (actual), __LINE__, (message))
|
||||||
|
|
||||||
|
#define TEST_ASSERT_LESS_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT64((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_CHAR((threshold), (actual), __LINE__, (message))
|
||||||
|
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, (message))
|
||||||
|
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_size_t_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_CHAR_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_CHAR((threshold), (actual), __LINE__, (message))
|
||||||
|
|
||||||
|
/* Integer Ranges (of all sizes) */
|
||||||
|
#define TEST_ASSERT_INT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_INT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT8_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_INT16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT16_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_INT32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT32_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_INT64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT64_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_UINT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_UINT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT8_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_UINT16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT16_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_UINT32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT32_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_UINT64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT64_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_size_t_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_HEX_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_HEX8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX8_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_HEX16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX16_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_HEX32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_HEX64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_CHAR_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_CHAR_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
|
||||||
|
/* Integer Array Ranges (of all sizes) */
|
||||||
|
#define TEST_ASSERT_INT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_INT8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_INT16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_INT32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_INT64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_INT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_UINT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_UINT8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_UINT16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_UINT32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_UINT64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_size_t_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_UINT_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_HEX_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_HEX8_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX8_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_HEX16_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX16_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_HEX32_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX32_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_HEX64_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_HEX64_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_CHAR_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_CHAR_ARRAY_WITHIN((delta), (expected), (actual), num_elements, __LINE__, (message))
|
||||||
|
|
||||||
|
|
||||||
|
/* Structs and Strings */
|
||||||
|
#define TEST_ASSERT_EQUAL_PTR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(expected, actual, len, message) UNITY_TEST_ASSERT_EQUAL_STRING_LEN((expected), (actual), (len), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_MEMORY_MESSAGE(expected, actual, len, message) UNITY_TEST_ASSERT_EQUAL_MEMORY((expected), (actual), (len), __LINE__, (message))
|
||||||
|
|
||||||
|
/* Arrays */
|
||||||
|
#define TEST_ASSERT_EQUAL_INT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_INT8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_INT16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_INT32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_INT64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_UINT64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_size_t_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_HEX64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_PTR_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_STRING_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_MEMORY_ARRAY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_CHAR_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_CHAR_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
|
||||||
|
/* Arrays Compared To Single Value*/
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_INT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_INT8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_INT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT16((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_INT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT32((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_INT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT64((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_UINT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_UINT8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT8((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_UINT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_UINT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_UINT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_size_t_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_HEX_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_HEX8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_HEX16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_HEX32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_HEX64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX64((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_PTR_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_STRING_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_MEMORY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_CHAR_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_CHAR((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
|
||||||
|
/* Floating Point (If Enabled) */
|
||||||
|
#define TEST_ASSERT_FLOAT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_FLOAT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_FLOAT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_FLOAT((expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_FLOAT_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_FLOAT_ARRAY_WITHIN((delta), (expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_FLOAT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_FLOAT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_FLOAT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_FLOAT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_THAN_FLOAT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_FLOAT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_OR_EQUAL_FLOAT((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_FLOAT_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_INF((actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_FLOAT_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF((actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_FLOAT_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NAN((actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_FLOAT_IS_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE((actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_FLOAT_IS_NOT_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF((actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_FLOAT_IS_NOT_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF((actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_FLOAT_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN((actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE((actual), __LINE__, (message))
|
||||||
|
|
||||||
|
/* Double (If Enabled) */
|
||||||
|
#define TEST_ASSERT_DOUBLE_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_DOUBLE_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_DOUBLE_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_NOT_EQUAL_DOUBLE((expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_DOUBLE_ARRAY_WITHIN_MESSAGE(delta, expected, actual, num_elements, message) UNITY_TEST_ASSERT_DOUBLE_ARRAY_WITHIN((delta), (expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EQUAL_DOUBLE_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_EACH_EQUAL_DOUBLE_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_THAN_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_DOUBLE((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_DOUBLE((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_THAN_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_THAN_DOUBLE((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_LESS_OR_EQUAL_DOUBLE_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_LESS_OR_EQUAL_DOUBLE((threshold), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_DOUBLE_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_INF((actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_DOUBLE_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF((actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_DOUBLE_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NAN((actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_DOUBLE_IS_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE((actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_DOUBLE_IS_NOT_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF((actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF((actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_DOUBLE_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN((actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, (message))
|
||||||
|
|
||||||
|
/* Shorthand */
|
||||||
|
#ifdef UNITY_SHORTHAND_AS_OLD
|
||||||
|
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message))
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, (message))
|
||||||
|
#endif
|
||||||
|
#ifdef UNITY_SHORTHAND_AS_INT
|
||||||
|
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, message)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
||||||
|
#endif
|
||||||
|
#ifdef UNITY_SHORTHAND_AS_MEM
|
||||||
|
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_MEMORY((&expected), (&actual), sizeof(expected), __LINE__, message)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
||||||
|
#endif
|
||||||
|
#ifdef UNITY_SHORTHAND_AS_RAW
|
||||||
|
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) == (actual)), __LINE__, message)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, message)
|
||||||
|
#endif
|
||||||
|
#ifdef UNITY_SHORTHAND_AS_NONE
|
||||||
|
#define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
||||||
|
#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_FAIL(__LINE__, UnityStrErrShorthand)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* end of UNITY_FRAMEWORK_H */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
1145
movement/lib/chirpy_tx/test/unity_internals.h
Normal file
1145
movement/lib/chirpy_tx/test/unity_internals.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -17,6 +17,7 @@ INCLUDES += \
|
||||||
-I../watch_faces/sensor/ \
|
-I../watch_faces/sensor/ \
|
||||||
-I../watch_faces/demo/ \
|
-I../watch_faces/demo/ \
|
||||||
-I../../littlefs/ \
|
-I../../littlefs/ \
|
||||||
|
-I../lib/chirpy_tx/ \
|
||||||
-I../lib/TOTP/ \
|
-I../lib/TOTP/ \
|
||||||
-I../lib/base32/ \
|
-I../lib/base32/ \
|
||||||
-I../lib/sunriset/ \
|
-I../lib/sunriset/ \
|
||||||
|
@ -31,6 +32,7 @@ INCLUDES += \
|
||||||
# ../drivers/lis2dh.c \
|
# ../drivers/lis2dh.c \
|
||||||
# ../watch_faces/fitness/step_count_face.c
|
# ../watch_faces/fitness/step_count_face.c
|
||||||
SRCS += \
|
SRCS += \
|
||||||
|
../lib/chirpy_tx/chirpy_tx.c \
|
||||||
../lib/TOTP/sha1.c \
|
../lib/TOTP/sha1.c \
|
||||||
../lib/TOTP/sha256.c \
|
../lib/TOTP/sha256.c \
|
||||||
../lib/TOTP/sha512.c \
|
../lib/TOTP/sha512.c \
|
||||||
|
@ -95,6 +97,8 @@ SRCS += \
|
||||||
../watch_faces/complication/tarot_face.c \
|
../watch_faces/complication/tarot_face.c \
|
||||||
../watch_faces/complication/morsecalc_face.c \
|
../watch_faces/complication/morsecalc_face.c \
|
||||||
../watch_faces/complication/rpn_calculator_face.c \
|
../watch_faces/complication/rpn_calculator_face.c \
|
||||||
|
../watch_faces/complication/activity_face.c \
|
||||||
|
../watch_faces/demo/chirpy_demo_face.c \
|
||||||
../watch_faces/complication/ships_bell_face.c \
|
../watch_faces/complication/ships_bell_face.c \
|
||||||
../watch_faces/complication/discgolf_face.c \
|
../watch_faces/complication/discgolf_face.c \
|
||||||
../watch_faces/complication/habit_face.c \
|
../watch_faces/complication/habit_face.c \
|
||||||
|
|
|
@ -73,6 +73,8 @@
|
||||||
#include "interval_face.h"
|
#include "interval_face.h"
|
||||||
#include "morsecalc_face.h"
|
#include "morsecalc_face.h"
|
||||||
#include "rpn_calculator_face.h"
|
#include "rpn_calculator_face.h"
|
||||||
|
#include "activity_face.h"
|
||||||
|
#include "chirpy_demo_face.h"
|
||||||
#include "ships_bell_face.h"
|
#include "ships_bell_face.h"
|
||||||
#include "discgolf_face.h"
|
#include "discgolf_face.h"
|
||||||
#include "habit_face.h"
|
#include "habit_face.h"
|
||||||
|
|
725
movement/watch_faces/complication/activity_face.c
Normal file
725
movement/watch_faces/complication/activity_face.c
Normal file
|
@ -0,0 +1,725 @@
|
||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Gabor L Ugray
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ** TODO
|
||||||
|
* ===================
|
||||||
|
* -- Additional power-saving optimizations
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "activity_face.h"
|
||||||
|
#include "chirpy_tx.h"
|
||||||
|
#include "watch.h"
|
||||||
|
#include "watch_utility.h"
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
// This part is configurable: you can edit values here to customize you activity face
|
||||||
|
// In particular, with num_enabled_activities and enabled_activities you can choose a subset of the
|
||||||
|
// activities that you want to see in your watch.
|
||||||
|
// You can also add new items to activity_names, but don't redefine or remove existing ones.
|
||||||
|
|
||||||
|
// If a logged activity is shorter than this, then it won't be added to log when it ends.
|
||||||
|
// This way scarce log slots are not taken up by aborted events that weren't real activities.
|
||||||
|
static const uint16_t activity_min_length_sec = 60;
|
||||||
|
|
||||||
|
// Supported activities. ID of activity is index in this buffer
|
||||||
|
// W e should never change order or redefine items, only add new items when needed.
|
||||||
|
static const char activity_names[][7] = {
|
||||||
|
" bIKE ",
|
||||||
|
"uuaLK ",
|
||||||
|
" rUn ",
|
||||||
|
"DAnCE ",
|
||||||
|
" yOgA ",
|
||||||
|
"CrOSS ",
|
||||||
|
"Suuinn",
|
||||||
|
"ELLIP ",
|
||||||
|
" gYnn",
|
||||||
|
" rOuu",
|
||||||
|
"SOCCEr",
|
||||||
|
" FOOTb",
|
||||||
|
" bALL ",
|
||||||
|
" SKI ",
|
||||||
|
};
|
||||||
|
|
||||||
|
// Currently enabled activities. This makes picking on first subface easier: why show activities you personally never do.
|
||||||
|
static const uint8_t enabled_activities[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
|
||||||
|
|
||||||
|
// Number of currently enabled activities (size of enabled_activities).
|
||||||
|
static const uint8_t num_enabled_activities = sizeof(enabled_activities) / sizeof(uint8_t);
|
||||||
|
|
||||||
|
// End configurable section
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
// One logged activity
|
||||||
|
typedef struct __attribute__((__packed__)) {
|
||||||
|
// Activity's start time
|
||||||
|
watch_date_time start_time;
|
||||||
|
|
||||||
|
// Total duration of activity, including time spend in paus
|
||||||
|
uint16_t total_sec;
|
||||||
|
|
||||||
|
// Number of seconds the activity was paused
|
||||||
|
uint16_t pause_sec;
|
||||||
|
|
||||||
|
// Type of activity (index in activity_names)
|
||||||
|
uint8_t activity_type;
|
||||||
|
|
||||||
|
} activity_item_t;
|
||||||
|
|
||||||
|
#define MAX_ACTIVITY_SECONDS 28800 // 8 hours = 28800 sec
|
||||||
|
|
||||||
|
// Size of (fixed) buffer to log activites. Takes up x9 bytes in SRAM if face is installed.
|
||||||
|
#define ACTIVITY_LOG_SZ 99
|
||||||
|
|
||||||
|
// Number of activities in buffer.
|
||||||
|
static uint8_t activity_log_count = 0;
|
||||||
|
|
||||||
|
// Buffer with all logged activities.
|
||||||
|
static activity_item_t activity_log_buffer[ACTIVITY_LOG_SZ];
|
||||||
|
|
||||||
|
#define CHIRPY_PREFIX_LEN 2
|
||||||
|
// First two bytes chirped out, to identify transmission as from the activity face
|
||||||
|
static const uint8_t activity_chirpy_prefix[CHIRPY_PREFIX_LEN] = {0x27, 0x00};
|
||||||
|
|
||||||
|
// The face's different UI modes (views).
|
||||||
|
typedef enum {
|
||||||
|
ACTM_CHOOSE = 0,
|
||||||
|
ACTM_LOGGING,
|
||||||
|
ACTM_PAUSED,
|
||||||
|
ACTM_DONE,
|
||||||
|
ACTM_LOGSIZE,
|
||||||
|
ACTM_CHIRP,
|
||||||
|
ACTM_CHIRPING,
|
||||||
|
ACTM_CLEAR,
|
||||||
|
ACTM_CLEAR_CONFIRM,
|
||||||
|
ACTM_CLEAR_DONE,
|
||||||
|
} activity_mode_t;
|
||||||
|
|
||||||
|
// The full state of the activity face
|
||||||
|
typedef struct {
|
||||||
|
// Current mode (which secondary face, or ongoing operation like logging)
|
||||||
|
activity_mode_t mode;
|
||||||
|
|
||||||
|
// Index of currently selected activity in enabled_activities
|
||||||
|
uint8_t type_ix;
|
||||||
|
|
||||||
|
// Used for different things depending on mode
|
||||||
|
// In ACTM_DONE: countdown for animation, before returning to start face
|
||||||
|
// In ACTM_LOGGING and ACTM_PAUSED: drives blinking colon and alternating time display
|
||||||
|
// In ACTM_LOGSIZE, ACTM_CLEAR: enables timeout return to choose screen
|
||||||
|
uint16_t counter;
|
||||||
|
|
||||||
|
// Start of currently logged activity, if any
|
||||||
|
watch_date_time start_time;
|
||||||
|
|
||||||
|
// Total seconds elapsed since logging started
|
||||||
|
uint16_t curr_total_sec;
|
||||||
|
|
||||||
|
// Total paused seconds in current log
|
||||||
|
uint16_t curr_pause_sec;
|
||||||
|
|
||||||
|
// Helps us handle 1/64 ticks during transmission; including countdown timer
|
||||||
|
chirpy_tick_state_t chirpy_tick_state;
|
||||||
|
|
||||||
|
// Used by chirpy encoder during transmission
|
||||||
|
chirpy_encoder_state_t chirpy_encoder_state;
|
||||||
|
|
||||||
|
// 0: Running normally
|
||||||
|
// 1: In LE mode
|
||||||
|
// 2: Just woke up from LE mode. Will go to 0 after ignoring ALARM_BUTTON_UP.
|
||||||
|
uint8_t le_state;
|
||||||
|
|
||||||
|
} activity_state_t;
|
||||||
|
|
||||||
|
#define ACTIVITY_BUF_SZ 14
|
||||||
|
|
||||||
|
// Temp buffer used for sprintf'ing content for the display.
|
||||||
|
char activity_buf[ACTIVITY_BUF_SZ];
|
||||||
|
|
||||||
|
// Needed by _activity_get_next_byte to keep track of where we are in transmission
|
||||||
|
uint16_t *activity_seq_pos;
|
||||||
|
|
||||||
|
static void _activity_clear_buffers() {
|
||||||
|
// Clear activity buffer; 0xcd is good for diagnostics
|
||||||
|
memset(activity_log_buffer, 0xcd, ACTIVITY_LOG_SZ * sizeof(activity_item_t));
|
||||||
|
// Clear display buffer
|
||||||
|
memset(activity_buf, 0, ACTIVITY_BUF_SZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _activity_display_choice(activity_state_t *state);
|
||||||
|
static void _activity_update_logging_screen(movement_settings_t *settings, activity_state_t *state);
|
||||||
|
static uint8_t _activity_get_next_byte(uint8_t *next_byte);
|
||||||
|
|
||||||
|
void activity_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr) {
|
||||||
|
(void)settings;
|
||||||
|
(void)watch_face_index;
|
||||||
|
if (*context_ptr == NULL) {
|
||||||
|
*context_ptr = malloc(sizeof(activity_state_t));
|
||||||
|
memset(*context_ptr, 0, sizeof(activity_state_t));
|
||||||
|
// This happens only at boot
|
||||||
|
_activity_clear_buffers();
|
||||||
|
}
|
||||||
|
// Do any pin or peripheral setup here; this will be called whenever the watch wakes from deep sleep.
|
||||||
|
}
|
||||||
|
|
||||||
|
void activity_face_activate(movement_settings_t *settings, void *context) {
|
||||||
|
(void)settings;
|
||||||
|
(void)context;
|
||||||
|
|
||||||
|
// Not using this function. Calling _activity_activate from the event handler.
|
||||||
|
// That is what we get both when the face is shown upon navigation by MODE,
|
||||||
|
// and when waking from low energy state.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called from the ACTIVATE event handler in the loop
|
||||||
|
static void _activity_activate(movement_settings_t *settings, activity_state_t *state) {
|
||||||
|
// If waking from low-energy state and currently logging: update seconds values
|
||||||
|
// Those are not up-to-date because ticks have not been coming
|
||||||
|
if (state->le_state != 0 && state->mode == ACTM_LOGGING) {
|
||||||
|
state->le_state = 2;
|
||||||
|
watch_date_time now = watch_rtc_get_date_time();
|
||||||
|
uint32_t now_timestamp = watch_utility_date_time_to_unix_time(now, 0);
|
||||||
|
uint32_t start_timestamp = watch_utility_date_time_to_unix_time(state->start_time, 0);
|
||||||
|
uint32_t total_seconds = now_timestamp - start_timestamp;
|
||||||
|
state->curr_total_sec = total_seconds;
|
||||||
|
_activity_update_logging_screen(settings, state);
|
||||||
|
}
|
||||||
|
// Regular activation: start from defaults
|
||||||
|
else {
|
||||||
|
state->le_state = 0;
|
||||||
|
state->mode = 0;
|
||||||
|
state->type_ix = 0;
|
||||||
|
_activity_display_choice(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _activity_display_choice(activity_state_t *state) {
|
||||||
|
watch_display_string("AC", 0);
|
||||||
|
// If buffer is full: We say "FULL"
|
||||||
|
if (activity_log_count >= ACTIVITY_LOG_SZ) {
|
||||||
|
watch_display_string(" FULL ", 4);
|
||||||
|
}
|
||||||
|
// Otherwise, we show currently activity
|
||||||
|
else {
|
||||||
|
uint8_t activity_ix = enabled_activities[state->type_ix];
|
||||||
|
const char *name = activity_names[activity_ix];
|
||||||
|
watch_display_string((char *)name, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint8_t activity_anim_pixels[][2] = {
|
||||||
|
{1, 4}, // TL
|
||||||
|
{0, 5}, // BL
|
||||||
|
{0, 6}, // BOT
|
||||||
|
{1, 6}, // BR
|
||||||
|
{2, 5}, // TR
|
||||||
|
{2, 4}, // TOP
|
||||||
|
// {2, 4}, // MID
|
||||||
|
};
|
||||||
|
|
||||||
|
static void _activity_update_logging_screen(movement_settings_t *settings, activity_state_t *state) {
|
||||||
|
watch_duration_t duration;
|
||||||
|
|
||||||
|
watch_display_string("AC ", 0);
|
||||||
|
|
||||||
|
// If we're in LE state: per-minute update is special
|
||||||
|
if (state->le_state == 1) {
|
||||||
|
watch_date_time now = watch_rtc_get_date_time();
|
||||||
|
uint32_t now_timestamp = watch_utility_date_time_to_unix_time(now, 0);
|
||||||
|
uint32_t start_timestamp = watch_utility_date_time_to_unix_time(state->start_time, 0);
|
||||||
|
uint32_t total_seconds = now_timestamp - start_timestamp;
|
||||||
|
duration = watch_utility_seconds_to_duration(total_seconds);
|
||||||
|
sprintf(activity_buf, " %d%02d ", duration.hours, duration.minutes);
|
||||||
|
watch_display_string(activity_buf, 4);
|
||||||
|
watch_set_colon();
|
||||||
|
watch_set_indicator(WATCH_INDICATOR_LAP);
|
||||||
|
watch_clear_indicator(WATCH_INDICATOR_PM);
|
||||||
|
watch_clear_indicator(WATCH_INDICATOR_24H);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show elapsed time, or PAUSE
|
||||||
|
if ((state->counter % 5) < 3) {
|
||||||
|
watch_set_indicator(WATCH_INDICATOR_LAP);
|
||||||
|
watch_clear_indicator(WATCH_INDICATOR_PM);
|
||||||
|
watch_clear_indicator(WATCH_INDICATOR_24H);
|
||||||
|
if (state->mode == ACTM_PAUSED) {
|
||||||
|
watch_display_string(" PAUSE", 4);
|
||||||
|
watch_clear_colon();
|
||||||
|
} else {
|
||||||
|
duration = watch_utility_seconds_to_duration(state->curr_total_sec);
|
||||||
|
// Under 10 minutes: M:SS
|
||||||
|
if (state->curr_total_sec < 600) {
|
||||||
|
sprintf(activity_buf, " %01d%02d", duration.minutes, duration.seconds);
|
||||||
|
watch_display_string(activity_buf, 4);
|
||||||
|
watch_clear_colon();
|
||||||
|
}
|
||||||
|
// Under an hour: MM:SS
|
||||||
|
else if (state->curr_total_sec < 3600) {
|
||||||
|
sprintf(activity_buf, " %02d%02d", duration.minutes, duration.seconds);
|
||||||
|
watch_display_string(activity_buf, 4);
|
||||||
|
watch_clear_colon();
|
||||||
|
}
|
||||||
|
// Over an hour: H:MM:SS
|
||||||
|
// (We never go to two-digit hours; stop at 8)
|
||||||
|
else {
|
||||||
|
sprintf(activity_buf, " %d%02d%02d", duration.hours, duration.minutes, duration.seconds);
|
||||||
|
watch_display_string(activity_buf, 4);
|
||||||
|
watch_set_colon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Briefly, show time without seconds
|
||||||
|
else {
|
||||||
|
watch_clear_indicator(WATCH_INDICATOR_LAP);
|
||||||
|
watch_date_time now = watch_rtc_get_date_time();
|
||||||
|
uint8_t hour = now.unit.hour;
|
||||||
|
if (!settings->bit.clock_mode_24h) {
|
||||||
|
watch_clear_indicator(WATCH_INDICATOR_24H);
|
||||||
|
if (hour < 12)
|
||||||
|
watch_clear_indicator(WATCH_INDICATOR_PM);
|
||||||
|
else
|
||||||
|
watch_set_indicator(WATCH_INDICATOR_PM);
|
||||||
|
hour %= 12;
|
||||||
|
if (hour == 0) hour = 12;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
watch_set_indicator(WATCH_INDICATOR_24H);
|
||||||
|
watch_clear_indicator(WATCH_INDICATOR_PM);
|
||||||
|
}
|
||||||
|
sprintf(activity_buf, "%2d%02d ", hour, now.unit.minute);
|
||||||
|
watch_set_colon();
|
||||||
|
watch_display_string(activity_buf, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _activity_quit_chirping() {
|
||||||
|
watch_clear_indicator(WATCH_INDICATOR_BELL);
|
||||||
|
watch_set_buzzer_off();
|
||||||
|
movement_request_tick_frequency(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _activity_chirp_tick_transmit(void *context) {
|
||||||
|
activity_state_t *state = (activity_state_t *)context;
|
||||||
|
|
||||||
|
uint8_t tone = chirpy_get_next_tone(&state->chirpy_encoder_state);
|
||||||
|
// Transmission over?
|
||||||
|
if (tone == 255) {
|
||||||
|
_activity_quit_chirping();
|
||||||
|
state->mode = ACTM_CHIRP;
|
||||||
|
state->counter = 0;
|
||||||
|
watch_display_string("AC CHIRP ", 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uint16_t period = chirpy_get_tone_period(tone);
|
||||||
|
watch_set_buzzer_period(period);
|
||||||
|
watch_set_buzzer_on();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _activity_chirp_tick_countdown(void *context) {
|
||||||
|
activity_state_t *state = (activity_state_t *)context;
|
||||||
|
|
||||||
|
// Countdown over: start actual broadcast
|
||||||
|
if (state->chirpy_tick_state.seq_pos == 8 * 3) {
|
||||||
|
state->chirpy_tick_state.tick_compare = 3;
|
||||||
|
state->chirpy_tick_state.tick_count = 2; // tick_compare - 1, so it starts immediately
|
||||||
|
state->chirpy_tick_state.seq_pos = 0;
|
||||||
|
state->chirpy_tick_state.tick_fun = _activity_chirp_tick_transmit;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Sound or turn off buzzer
|
||||||
|
if ((state->chirpy_tick_state.seq_pos % 8) == 0) {
|
||||||
|
watch_set_buzzer_period(NotePeriods[BUZZER_NOTE_A5]);
|
||||||
|
watch_set_buzzer_on();
|
||||||
|
if (state->chirpy_tick_state.seq_pos == 0) {
|
||||||
|
watch_display_string(" --- ", 4);
|
||||||
|
} else if (state->chirpy_tick_state.seq_pos == 8) {
|
||||||
|
watch_display_string(" --", 5);
|
||||||
|
} else if (state->chirpy_tick_state.seq_pos == 16) {
|
||||||
|
watch_display_string(" -", 5);
|
||||||
|
}
|
||||||
|
} else if ((state->chirpy_tick_state.seq_pos % 8) == 1) {
|
||||||
|
watch_set_buzzer_off();
|
||||||
|
}
|
||||||
|
++state->chirpy_tick_state.seq_pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t _activity_get_next_byte(uint8_t *next_byte) {
|
||||||
|
uint16_t num_bytes = 2 + activity_log_count * sizeof(activity_item_t);
|
||||||
|
uint16_t pos = *activity_seq_pos;
|
||||||
|
|
||||||
|
// Init counter
|
||||||
|
if (pos == 0) {
|
||||||
|
sprintf(activity_buf, "%3d", activity_log_count);
|
||||||
|
watch_display_string(activity_buf, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos == num_bytes) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// Two-byte prefix
|
||||||
|
if (pos < 2) {
|
||||||
|
(*next_byte) = activity_chirpy_prefix[pos];
|
||||||
|
}
|
||||||
|
// Data
|
||||||
|
else {
|
||||||
|
pos -= 2;
|
||||||
|
uint16_t ix = pos / sizeof(activity_item_t);
|
||||||
|
const activity_item_t *itm = &activity_log_buffer[ix];
|
||||||
|
uint16_t ofs = pos % sizeof(activity_item_t);
|
||||||
|
|
||||||
|
// Update counter when starting new item
|
||||||
|
if (ofs == 0) {
|
||||||
|
sprintf(activity_buf, "%3d", activity_log_count - ix);
|
||||||
|
watch_display_string(activity_buf, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do this the hard way, byte by byte, to avoid high/low endedness issues
|
||||||
|
// Higher order bytes first, is our serialization format
|
||||||
|
uint8_t val;
|
||||||
|
// watch_date_time start_time;
|
||||||
|
// uint16_t total_sec;
|
||||||
|
// uint16_t pause_sec;
|
||||||
|
// uint8_t activity_type;
|
||||||
|
if (ofs == 0)
|
||||||
|
val = (itm->start_time.reg & 0xff000000) >> 24;
|
||||||
|
else if (ofs == 1)
|
||||||
|
val = (itm->start_time.reg & 0x00ff0000) >> 16;
|
||||||
|
else if (ofs == 2)
|
||||||
|
val = (itm->start_time.reg & 0x0000ff00) >> 8;
|
||||||
|
else if (ofs == 3)
|
||||||
|
val = (itm->start_time.reg & 0x000000ff);
|
||||||
|
else if (ofs == 4)
|
||||||
|
val = (itm->total_sec & 0xff00) >> 8;
|
||||||
|
else if (ofs == 5)
|
||||||
|
val = (itm->total_sec & 0x00ff);
|
||||||
|
else if (ofs == 6)
|
||||||
|
val = (itm->pause_sec & 0xff00) >> 8;
|
||||||
|
else if (ofs == 7)
|
||||||
|
val = (itm->pause_sec & 0x00ff);
|
||||||
|
else
|
||||||
|
val = itm->activity_type;
|
||||||
|
(*next_byte) = val;
|
||||||
|
}
|
||||||
|
++(*activity_seq_pos);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _activity_finish_logging(activity_state_t *state) {
|
||||||
|
// Save this activity
|
||||||
|
// If shorter than minimum for log: don't save
|
||||||
|
// Sanity check about buffer length. This should never happen, but also we never want to overrun by error
|
||||||
|
if (state->curr_total_sec >= activity_min_length_sec && activity_log_count + 1 < ACTIVITY_LOG_SZ) {
|
||||||
|
activity_item_t *itm = &activity_log_buffer[activity_log_count];
|
||||||
|
itm->start_time = state->start_time;
|
||||||
|
itm->total_sec = state->curr_total_sec;
|
||||||
|
itm->pause_sec = state->curr_pause_sec;
|
||||||
|
itm->activity_type = state->type_ix;
|
||||||
|
++activity_log_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Go to DONE animation
|
||||||
|
// TODO: Not in LE mode
|
||||||
|
state->mode = ACTM_DONE;
|
||||||
|
watch_clear_indicator(WATCH_INDICATOR_LAP);
|
||||||
|
movement_request_tick_frequency(2);
|
||||||
|
state->counter = 6 * 1;
|
||||||
|
watch_clear_display();
|
||||||
|
watch_display_string("AC dONE ", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _activity_handle_tick(movement_settings_t *settings, activity_state_t *state) {
|
||||||
|
// Display stopwatch-like duration while logging, alternating with time
|
||||||
|
if (state->mode == ACTM_LOGGING || state->mode == ACTM_PAUSED) {
|
||||||
|
++state->counter;
|
||||||
|
++state->curr_total_sec;
|
||||||
|
if (state->mode == ACTM_PAUSED)
|
||||||
|
++state->curr_pause_sec;
|
||||||
|
// If we've reached max activity length: finish logging
|
||||||
|
if (state->curr_total_sec == MAX_ACTIVITY_SECONDS) {
|
||||||
|
_activity_finish_logging(state);
|
||||||
|
}
|
||||||
|
// Still logging: refresh display
|
||||||
|
else {
|
||||||
|
_activity_update_logging_screen(settings, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Display countown animation, and exit face when down
|
||||||
|
else if (state->mode == ACTM_DONE) {
|
||||||
|
if (state->counter == 0) {
|
||||||
|
movement_move_to_face(0);
|
||||||
|
movement_request_tick_frequency(1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
uint8_t cd = state->counter % 6;
|
||||||
|
watch_clear_pixel(activity_anim_pixels[cd][0], activity_anim_pixels[cd][1]);
|
||||||
|
--state->counter;
|
||||||
|
cd = state->counter % 6;
|
||||||
|
watch_set_pixel(activity_anim_pixels[cd][0], activity_anim_pixels[cd][1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Log size, chirp, clear: return to choose after some time
|
||||||
|
else if (state->mode == ACTM_LOGSIZE || state->mode == ACTM_CHIRP || state->mode == ACTM_CLEAR) {
|
||||||
|
++state->counter;
|
||||||
|
// Leave Log Size after 20 seconds
|
||||||
|
// Leave Clear after only 10: this is danger zone, we don't like hanging around here
|
||||||
|
// Leave Chirp after 2 minutes: most likely need to the time to fiddle with mic & Chirpy RX on the computer
|
||||||
|
uint16_t timeout = 20;
|
||||||
|
if (state->mode == ACTM_CLEAR) timeout = 10;
|
||||||
|
else if (state->mode == ACTM_CHIRP) timeout = 120;
|
||||||
|
if (state->counter > timeout) {
|
||||||
|
state->mode = ACTM_CHOOSE;
|
||||||
|
_activity_display_choice(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Chirping
|
||||||
|
else if (state->mode == ACTM_CHIRPING) {
|
||||||
|
++state->chirpy_tick_state.tick_count;
|
||||||
|
if (state->chirpy_tick_state.tick_count == state->chirpy_tick_state.tick_compare) {
|
||||||
|
state->chirpy_tick_state.tick_count = 0;
|
||||||
|
state->chirpy_tick_state.tick_fun(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Clear confirm: blink CLEAR
|
||||||
|
else if (state->mode == ACTM_CLEAR_CONFIRM) {
|
||||||
|
++state->counter;
|
||||||
|
if ((state->counter % 2) == 0)
|
||||||
|
watch_display_string("CLEAR ", 4);
|
||||||
|
else
|
||||||
|
watch_display_string(" ", 4);
|
||||||
|
if (state->counter > 12) {
|
||||||
|
state->mode = ACTM_CHOOSE;
|
||||||
|
_activity_display_choice(state);
|
||||||
|
movement_request_tick_frequency(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Clear done: fill up zeroes, then return to choose screen
|
||||||
|
else if (state->mode == ACTM_CLEAR_DONE) {
|
||||||
|
++state->counter;
|
||||||
|
// Animation done
|
||||||
|
if (state->counter == 7) {
|
||||||
|
state->mode = ACTM_CHOOSE;
|
||||||
|
_activity_display_choice(state);
|
||||||
|
movement_request_tick_frequency(1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Display current state of animation
|
||||||
|
sprintf(activity_buf, " ");
|
||||||
|
uint8_t nZeros = state->counter + 1;
|
||||||
|
if (nZeros > 6) nZeros = 6;
|
||||||
|
for (uint8_t i = 0; i < nZeros; ++i) {
|
||||||
|
activity_buf[i] = '0';
|
||||||
|
}
|
||||||
|
watch_display_string(activity_buf, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _activity_alarm_long(movement_settings_t *settings, activity_state_t *state) {
|
||||||
|
// On choose face: start logging activity
|
||||||
|
if (state->mode == ACTM_CHOOSE) {
|
||||||
|
// If buffer is full: Ignore this long press
|
||||||
|
if (activity_log_count >= ACTIVITY_LOG_SZ)
|
||||||
|
return;
|
||||||
|
// OK, we go ahead and start logging
|
||||||
|
state->start_time = watch_rtc_get_date_time();
|
||||||
|
state->curr_total_sec = 0;
|
||||||
|
state->curr_pause_sec = 0;
|
||||||
|
state->counter = -1;
|
||||||
|
state->mode = ACTM_LOGGING;
|
||||||
|
watch_set_indicator(WATCH_INDICATOR_LAP);
|
||||||
|
_activity_update_logging_screen(settings, state);
|
||||||
|
}
|
||||||
|
// If logging or paused: end logging
|
||||||
|
else if (state->mode == ACTM_LOGGING || state->mode == ACTM_PAUSED) {
|
||||||
|
_activity_finish_logging(state);
|
||||||
|
}
|
||||||
|
// If chirp: kick off chirping
|
||||||
|
else if (state->mode == ACTM_CHIRP) {
|
||||||
|
// Set up our tick handling for countdown beeps
|
||||||
|
activity_seq_pos = &state->chirpy_tick_state.seq_pos;
|
||||||
|
state->chirpy_tick_state.tick_compare = 8;
|
||||||
|
state->chirpy_tick_state.tick_count = 7; // tick_compare - 1, so it starts immediately
|
||||||
|
state->chirpy_tick_state.seq_pos = 0;
|
||||||
|
state->chirpy_tick_state.tick_fun = _activity_chirp_tick_countdown;
|
||||||
|
// Set up chirpy encoder
|
||||||
|
chirpy_init_encoder(&state->chirpy_encoder_state, _activity_get_next_byte);
|
||||||
|
// Show bell; switch to 64/sec ticks
|
||||||
|
watch_set_indicator(WATCH_INDICATOR_BELL);
|
||||||
|
movement_request_tick_frequency(64);
|
||||||
|
state->mode = ACTM_CHIRPING;
|
||||||
|
}
|
||||||
|
// If clear: confirm (unless empty)
|
||||||
|
else if (state->mode == ACTM_CLEAR) {
|
||||||
|
if (activity_log_count == 0)
|
||||||
|
return;
|
||||||
|
state->mode = ACTM_CLEAR_CONFIRM;
|
||||||
|
state->counter = -1;
|
||||||
|
movement_request_tick_frequency(4);
|
||||||
|
}
|
||||||
|
// If clear confirm: do clear.
|
||||||
|
else if (state->mode == ACTM_CLEAR_CONFIRM) {
|
||||||
|
_activity_clear_buffers();
|
||||||
|
activity_log_count = 0;
|
||||||
|
state->mode = ACTM_CLEAR_DONE;
|
||||||
|
state->counter = -1;
|
||||||
|
watch_display_string("0 ", 4);
|
||||||
|
movement_request_tick_frequency(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _activity_alarm_short(movement_settings_t *settings, activity_state_t *state) {
|
||||||
|
// In the choose face, short ALARM cycles through activities
|
||||||
|
if (state->mode == ACTM_CHOOSE) {
|
||||||
|
state->type_ix = (state->type_ix + 1) % num_enabled_activities;
|
||||||
|
_activity_display_choice(state);
|
||||||
|
}
|
||||||
|
// If logging: pause
|
||||||
|
else if (state->mode == ACTM_LOGGING) {
|
||||||
|
state->mode = ACTM_PAUSED;
|
||||||
|
state->counter = 0;
|
||||||
|
_activity_update_logging_screen(settings, state);
|
||||||
|
}
|
||||||
|
// If paused: Update paused seconds count and return to logging
|
||||||
|
else if (state->mode == ACTM_PAUSED) {
|
||||||
|
state->mode = ACTM_LOGGING;
|
||||||
|
state->counter = 0;
|
||||||
|
_activity_update_logging_screen(settings, state);
|
||||||
|
}
|
||||||
|
// If chirping: stoppit
|
||||||
|
else if (state->mode == ACTM_CHIRPING) {
|
||||||
|
_activity_quit_chirping();
|
||||||
|
state->mode = ACTM_CHIRP;
|
||||||
|
state->counter = 0;
|
||||||
|
watch_display_string("AC CHIRP ", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _activity_light_short(activity_state_t *state) {
|
||||||
|
// If choose face: move to log size
|
||||||
|
if (state->mode == ACTM_CHOOSE) {
|
||||||
|
state->mode = ACTM_LOGSIZE;
|
||||||
|
state->counter = 0;
|
||||||
|
sprintf(activity_buf, "AC L#g%3d", activity_log_count);
|
||||||
|
watch_display_string(activity_buf, 0);
|
||||||
|
}
|
||||||
|
// If log size face: move to chirp
|
||||||
|
else if (state->mode == ACTM_LOGSIZE) {
|
||||||
|
state->mode = ACTM_CHIRP;
|
||||||
|
state->counter = 0;
|
||||||
|
watch_display_string("AC CHIRP ", 0);
|
||||||
|
}
|
||||||
|
// If chirp face: move to clear
|
||||||
|
else if (state->mode == ACTM_CHIRP) {
|
||||||
|
state->mode = ACTM_CLEAR;
|
||||||
|
state->counter = 0;
|
||||||
|
watch_display_string("AC CLEAR ", 0);
|
||||||
|
}
|
||||||
|
// If clear face: return to choose face
|
||||||
|
else if (state->mode == ACTM_CLEAR || state->mode == ACTM_CLEAR_CONFIRM) {
|
||||||
|
state->mode = ACTM_CHOOSE;
|
||||||
|
_activity_display_choice(state);
|
||||||
|
movement_request_tick_frequency(1);
|
||||||
|
}
|
||||||
|
// While logging or paused, light is light
|
||||||
|
else if (state->mode == ACTM_LOGGING || state->mode == ACTM_PAUSED) {
|
||||||
|
movement_illuminate_led();
|
||||||
|
}
|
||||||
|
// Otherwise, we don't do light.
|
||||||
|
}
|
||||||
|
|
||||||
|
bool activity_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||||
|
activity_state_t *state = (activity_state_t *)context;
|
||||||
|
|
||||||
|
switch (event.event_type) {
|
||||||
|
case EVENT_ACTIVATE:
|
||||||
|
_activity_activate(settings, state);
|
||||||
|
break;
|
||||||
|
case EVENT_TICK:
|
||||||
|
_activity_handle_tick(settings, state);
|
||||||
|
break;
|
||||||
|
case EVENT_MODE_BUTTON_UP:
|
||||||
|
if (state->mode != ACTM_LOGGING && state->mode != ACTM_PAUSED && state->mode != ACTM_CHIRPING) {
|
||||||
|
movement_request_tick_frequency(1);
|
||||||
|
movement_move_to_next_face();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EVENT_LIGHT_BUTTON_UP:
|
||||||
|
_activity_light_short(state);
|
||||||
|
break;
|
||||||
|
case EVENT_ALARM_BUTTON_UP:
|
||||||
|
// We also receive ALARM press that woke us up from LE state
|
||||||
|
// Don't want to act on that as if it were a real button press for us
|
||||||
|
if (state->le_state != 2)
|
||||||
|
_activity_alarm_short(settings, state);
|
||||||
|
else
|
||||||
|
state->le_state = 0;
|
||||||
|
break;
|
||||||
|
case EVENT_ALARM_LONG_PRESS:
|
||||||
|
_activity_alarm_long(settings, state);
|
||||||
|
break;
|
||||||
|
case EVENT_TIMEOUT:
|
||||||
|
if (state->mode != ACTM_LOGGING && state->mode != ACTM_PAUSED &&
|
||||||
|
state->mode != ACTM_CHIRP && state->mode != ACTM_CHIRPING) {
|
||||||
|
movement_request_tick_frequency(1);
|
||||||
|
movement_move_to_face(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EVENT_LOW_ENERGY_UPDATE:
|
||||||
|
state->le_state = 1;
|
||||||
|
// If we're in paused logging mode: let's lose this activity. Pause is not meant for over an hour.
|
||||||
|
if (state->mode == ACTM_PAUSED) {
|
||||||
|
// When waking, face will revert to default screen
|
||||||
|
state->mode = ACTM_CHOOSE;
|
||||||
|
watch_display_string("AC SLEEP ", 0);
|
||||||
|
watch_clear_colon();
|
||||||
|
watch_clear_indicator(WATCH_INDICATOR_LAP);
|
||||||
|
watch_clear_indicator(WATCH_INDICATOR_PM);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_activity_update_logging_screen(settings, state);
|
||||||
|
watch_start_tick_animation(500);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
movement_default_loop_handler(event, settings);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return true if the watch can enter standby mode. False needed when chirping.
|
||||||
|
if (state->mode == ACTM_CHIRPING)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void activity_face_resign(movement_settings_t *settings, void *context) {
|
||||||
|
(void)settings;
|
||||||
|
(void)context;
|
||||||
|
|
||||||
|
// Face should only ever temporarily request a higher frequency, so by the time we're resigning,
|
||||||
|
// this should not be needed. But we don't want an error to create a situation that drains the battery.
|
||||||
|
// Rather do this defensively here.
|
||||||
|
movement_request_tick_frequency(1);
|
||||||
|
}
|
89
movement/watch_faces/complication/activity_face.h
Normal file
89
movement/watch_faces/complication/activity_face.h
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Gabor L Ugray
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ACTIVITY_FACE_H_
|
||||||
|
#define ACTIVITY_FACE_H_
|
||||||
|
|
||||||
|
#include "movement.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ACTIVITY WATCH FACE
|
||||||
|
*
|
||||||
|
* The Activity face lets you record activities like you would do with a fitness watch.
|
||||||
|
* It supports different activities like running, biking, rowing etc., and for each recorded activity
|
||||||
|
* it stores when it started and how long it was.
|
||||||
|
*
|
||||||
|
* You can save up to 99 activities this way. Every once in a while you can chirp them out
|
||||||
|
* using the watch's piezo buzzer as a modem, then clear the log in the watch.
|
||||||
|
* To record and decode a chirpy transmission on your computer, you can use the web app here:
|
||||||
|
* https://jealousmarkup.xyz/off/chirpy/rx/
|
||||||
|
*
|
||||||
|
* Using the face
|
||||||
|
*
|
||||||
|
* When you activate the face, it starts with the first screen to select the activity you want to log.
|
||||||
|
* ALARM cycles through the list of activities.
|
||||||
|
* LONG ALARM starts logging.
|
||||||
|
* While logging is in progress, the face alternates between the elapsed time and the current time.
|
||||||
|
* You can press ALARM to pause (e.g., while you hop in to the baker's for a croissant during your jog).
|
||||||
|
* Pressing ALARM again resumes the activity.
|
||||||
|
* LONG ALARM stops logging and saves the activity.
|
||||||
|
*
|
||||||
|
* When you're not loggin, you can press LIGHT to access the secondary faces.
|
||||||
|
* LIGHT #1 => Shows the size of the log (how many activities have been recorded).
|
||||||
|
* LIGHT #2 => The screen to chirp out the data. Press LONG ALARM to start chirping.
|
||||||
|
* LIGHT #3 => The screen to clear the log in the watch. Press LONG ALARM twice to clear data.
|
||||||
|
*
|
||||||
|
* Quirky details
|
||||||
|
*
|
||||||
|
* The face will discard short activities (less than a minute) when you press LONG ALARM to finish logging.
|
||||||
|
* These were probably logged by mistake, and it's better to save slots and chirping battery power for
|
||||||
|
* stuff that really matters.
|
||||||
|
*
|
||||||
|
* The face will continue to record an activity past the normal one-hour mark, when the watch
|
||||||
|
* enters low energy mode. However, it will always stop at 8 hours. If an activity takes that long,
|
||||||
|
* you probably just forgot to stop logging.
|
||||||
|
*
|
||||||
|
* The log is stored in regular memory. It will be lost when you remove the battery, so make
|
||||||
|
* sure you chirp it out before taking the watch apart.
|
||||||
|
*
|
||||||
|
* See the top of activity_face.c for some customization options. What you most likely want to do
|
||||||
|
* is reduce the list of activities shown on the first screen to the ones you are regularly doing.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
void activity_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||||
|
void activity_face_activate(movement_settings_t *settings, void *context);
|
||||||
|
bool activity_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||||
|
void activity_face_resign(movement_settings_t *settings, void *context);
|
||||||
|
|
||||||
|
#define activity_face ((const watch_face_t){ \
|
||||||
|
activity_face_setup, \
|
||||||
|
activity_face_activate, \
|
||||||
|
activity_face_loop, \
|
||||||
|
activity_face_resign, \
|
||||||
|
NULL, \
|
||||||
|
})
|
||||||
|
|
||||||
|
#endif // ACTIVITY_FACE_H_
|
||||||
|
|
335
movement/watch_faces/demo/chirpy_demo_face.c
Normal file
335
movement/watch_faces/demo/chirpy_demo_face.c
Normal file
|
@ -0,0 +1,335 @@
|
||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Gabor L Ugray
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "chirpy_demo_face.h"
|
||||||
|
#include "chirpy_tx.h"
|
||||||
|
#include "filesystem.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CDM_CHOOSE = 0,
|
||||||
|
CDM_CHIRPING,
|
||||||
|
} chirpy_demo_mode_t;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CDP_SCALE = 0,
|
||||||
|
CDP_INFO_SHORT,
|
||||||
|
CDP_INFO_LONG,
|
||||||
|
CDP_INFO_NANOSEC,
|
||||||
|
} chirpy_demo_program_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
// Current mode
|
||||||
|
chirpy_demo_mode_t mode;
|
||||||
|
|
||||||
|
// Selected program
|
||||||
|
chirpy_demo_program_t program;
|
||||||
|
|
||||||
|
// Helps us handle 1/64 ticks during transmission; including countdown timer
|
||||||
|
chirpy_tick_state_t tick_state;
|
||||||
|
|
||||||
|
// Used by chirpy encoder during transmission
|
||||||
|
chirpy_encoder_state_t encoder_state;
|
||||||
|
|
||||||
|
} chirpy_demo_state_t;
|
||||||
|
|
||||||
|
static uint8_t long_data_str[] =
|
||||||
|
"There once was a ship that put to sea\n"
|
||||||
|
"The name of the ship was the Billy of Tea\n"
|
||||||
|
"The winds blew up, her bow dipped down\n"
|
||||||
|
"O blow, my bully boys, blow (huh)\n"
|
||||||
|
"\n"
|
||||||
|
"Soon may the Wellerman come\n"
|
||||||
|
"To bring us sugar and tea and rum\n"
|
||||||
|
"One day, when the tonguin' is done\n"
|
||||||
|
"We'll take our leave and go\n";
|
||||||
|
|
||||||
|
static uint16_t short_data_len = 20;
|
||||||
|
|
||||||
|
static uint8_t short_data[] = {
|
||||||
|
0x27,
|
||||||
|
0x00,
|
||||||
|
0x0c,
|
||||||
|
0x42,
|
||||||
|
0xa3,
|
||||||
|
0xd4,
|
||||||
|
0x06,
|
||||||
|
0x54,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x02,
|
||||||
|
0x0c,
|
||||||
|
0x6b,
|
||||||
|
0x05,
|
||||||
|
0x5a,
|
||||||
|
0x09,
|
||||||
|
0xd8,
|
||||||
|
0x00,
|
||||||
|
0xf5,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define NANOSEC_INI_FILE_NAME "nanosec.ini"
|
||||||
|
|
||||||
|
static uint8_t *nanosec_buffer = 0;
|
||||||
|
static uint16_t nanosec_buffer_size = 0;
|
||||||
|
|
||||||
|
void chirpy_demo_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr) {
|
||||||
|
(void)settings;
|
||||||
|
(void)watch_face_index;
|
||||||
|
if (*context_ptr == NULL) {
|
||||||
|
*context_ptr = malloc(sizeof(chirpy_demo_state_t));
|
||||||
|
memset(*context_ptr, 0, sizeof(chirpy_demo_state_t));
|
||||||
|
// Do any one-time tasks in here; the inside of this conditional happens only at boot.
|
||||||
|
}
|
||||||
|
// Do any pin or peripheral setup here; this will be called whenever the watch wakes from deep sleep.
|
||||||
|
}
|
||||||
|
|
||||||
|
void chirpy_demo_face_activate(movement_settings_t *settings, void *context) {
|
||||||
|
(void)settings;
|
||||||
|
chirpy_demo_state_t *state = (chirpy_demo_state_t *)context;
|
||||||
|
|
||||||
|
memset(context, 0, sizeof(chirpy_demo_state_t));
|
||||||
|
state->mode = CDM_CHOOSE;
|
||||||
|
state->program = CDP_SCALE;
|
||||||
|
|
||||||
|
// Do we have nanosec data? Load it.
|
||||||
|
int32_t sz = filesystem_get_file_size(NANOSEC_INI_FILE_NAME);
|
||||||
|
if (sz > 0) {
|
||||||
|
// We will free this in resign.
|
||||||
|
// I don't like any kind of dynamic allocation in long-running embedded software...
|
||||||
|
// But there's no way around it here; I don't want to hard-wire (and squat) any fixed size structure
|
||||||
|
// Nanosec data may change in the future too
|
||||||
|
nanosec_buffer_size = sz + 2;
|
||||||
|
nanosec_buffer = malloc(nanosec_buffer_size);
|
||||||
|
// First two bytes of prefix, so Chirpy RX can recognize this data type
|
||||||
|
nanosec_buffer[0] = 0xc0;
|
||||||
|
nanosec_buffer[1] = 0x00;
|
||||||
|
// Read file
|
||||||
|
filesystem_read_file(NANOSEC_INI_FILE_NAME, (char*)&nanosec_buffer[2], sz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// To create / check test file in emulator:
|
||||||
|
// echo TestData > nanosec.ini
|
||||||
|
// cat nanosec.ini
|
||||||
|
|
||||||
|
static void _cdf_update_lcd(chirpy_demo_state_t *state) {
|
||||||
|
watch_display_string("CH", 0);
|
||||||
|
if (state->program == CDP_SCALE)
|
||||||
|
watch_display_string(" SCALE", 4);
|
||||||
|
else if (state->program == CDP_INFO_SHORT)
|
||||||
|
watch_display_string("SHORT ", 4);
|
||||||
|
else if (state->program == CDP_INFO_LONG)
|
||||||
|
watch_display_string(" LOng ", 4);
|
||||||
|
else if (state->program == CDP_INFO_NANOSEC)
|
||||||
|
watch_display_string("nAnO ", 4);
|
||||||
|
else
|
||||||
|
watch_display_string("---- ", 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _cdf_quit_chirping(chirpy_demo_state_t *state) {
|
||||||
|
state->mode = CDM_CHOOSE;
|
||||||
|
watch_set_buzzer_off();
|
||||||
|
watch_clear_indicator(WATCH_INDICATOR_BELL);
|
||||||
|
movement_request_tick_frequency(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _cdf_scale_tick(void *context) {
|
||||||
|
chirpy_demo_state_t *state = (chirpy_demo_state_t *)context;
|
||||||
|
chirpy_tick_state_t *tick_state = &state->tick_state;
|
||||||
|
|
||||||
|
// Scale goes in 200Hz increments from 700 Hz to 12.3 kHz -> 58 steps
|
||||||
|
if (tick_state->seq_pos == 58) {
|
||||||
|
_cdf_quit_chirping(state);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uint32_t freq = 700 + tick_state->seq_pos * 200;
|
||||||
|
uint32_t period = 1000000 / freq;
|
||||||
|
watch_set_buzzer_period(period);
|
||||||
|
watch_set_buzzer_on();
|
||||||
|
++tick_state->seq_pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _cdf_data_tick(void *context) {
|
||||||
|
chirpy_demo_state_t *state = (chirpy_demo_state_t *)context;
|
||||||
|
|
||||||
|
uint8_t tone = chirpy_get_next_tone(&state->encoder_state);
|
||||||
|
// Transmission over?
|
||||||
|
if (tone == 255) {
|
||||||
|
_cdf_quit_chirping(state);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uint16_t period = chirpy_get_tone_period(tone);
|
||||||
|
watch_set_buzzer_period(period);
|
||||||
|
watch_set_buzzer_on();
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t *curr_data_ptr;
|
||||||
|
static uint16_t curr_data_ix;
|
||||||
|
static uint16_t curr_data_len;
|
||||||
|
|
||||||
|
static uint8_t _cdf_get_next_byte(uint8_t *next_byte) {
|
||||||
|
if (curr_data_ix == curr_data_len)
|
||||||
|
return 0;
|
||||||
|
*next_byte = curr_data_ptr[curr_data_ix];
|
||||||
|
++curr_data_ix;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _cdf_countdown_tick(void *context) {
|
||||||
|
chirpy_demo_state_t *state = (chirpy_demo_state_t *)context;
|
||||||
|
chirpy_tick_state_t *tick_state = &state->tick_state;
|
||||||
|
|
||||||
|
// Countdown over: start actual broadcast
|
||||||
|
if (tick_state->seq_pos == 8 * 3) {
|
||||||
|
tick_state->tick_compare = 3;
|
||||||
|
tick_state->tick_count = -1;
|
||||||
|
tick_state->seq_pos = 0;
|
||||||
|
// We'll be chirping out a scale
|
||||||
|
if (state->program == CDP_SCALE) {
|
||||||
|
tick_state->tick_fun = _cdf_scale_tick;
|
||||||
|
}
|
||||||
|
// We'll be chirping out data
|
||||||
|
else {
|
||||||
|
// Set up the encoder
|
||||||
|
chirpy_init_encoder(&state->encoder_state, _cdf_get_next_byte);
|
||||||
|
tick_state->tick_fun = _cdf_data_tick;
|
||||||
|
// Set up the data
|
||||||
|
curr_data_ix = 0;
|
||||||
|
if (state->program == CDP_INFO_SHORT) {
|
||||||
|
curr_data_ptr = short_data;
|
||||||
|
curr_data_len = short_data_len;
|
||||||
|
} else if (state->program == CDP_INFO_LONG) {
|
||||||
|
curr_data_ptr = long_data_str;
|
||||||
|
curr_data_len = strlen((const char *)long_data_str);
|
||||||
|
} else if (state->program == CDP_INFO_NANOSEC) {
|
||||||
|
curr_data_ptr = nanosec_buffer;
|
||||||
|
curr_data_len = nanosec_buffer_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Sound or turn off buzzer
|
||||||
|
if ((tick_state->seq_pos % 8) == 0) {
|
||||||
|
watch_set_buzzer_period(NotePeriods[BUZZER_NOTE_A5]);
|
||||||
|
watch_set_buzzer_on();
|
||||||
|
} else if ((tick_state->seq_pos % 8) == 1) {
|
||||||
|
watch_set_buzzer_off();
|
||||||
|
}
|
||||||
|
++tick_state->seq_pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _cdm_setup_chirp(chirpy_demo_state_t *state) {
|
||||||
|
// We want frequent callbacks from now on
|
||||||
|
movement_request_tick_frequency(64);
|
||||||
|
watch_set_indicator(WATCH_INDICATOR_BELL);
|
||||||
|
state->mode = CDM_CHIRPING;
|
||||||
|
// Set up tick state; start with countdown
|
||||||
|
state->tick_state.tick_count = -1;
|
||||||
|
state->tick_state.tick_compare = 8;
|
||||||
|
state->tick_state.seq_pos = 0;
|
||||||
|
state->tick_state.tick_fun = _cdf_countdown_tick;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool chirpy_demo_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||||
|
(void)settings;
|
||||||
|
chirpy_demo_state_t *state = (chirpy_demo_state_t *)context;
|
||||||
|
|
||||||
|
switch (event.event_type) {
|
||||||
|
case EVENT_ACTIVATE:
|
||||||
|
_cdf_update_lcd(state);
|
||||||
|
break;
|
||||||
|
case EVENT_MODE_BUTTON_UP:
|
||||||
|
// Do not exit face while we're chirping
|
||||||
|
if (state->mode != CDM_CHIRPING) {
|
||||||
|
movement_move_to_next_face();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EVENT_LIGHT_BUTTON_UP:
|
||||||
|
// We don't do light.
|
||||||
|
break;
|
||||||
|
case EVENT_ALARM_BUTTON_UP:
|
||||||
|
// If in choose mode: select next program
|
||||||
|
if (state->mode == CDM_CHOOSE) {
|
||||||
|
if (state->program == CDP_SCALE)
|
||||||
|
state->program = CDP_INFO_SHORT;
|
||||||
|
else if (state->program == CDP_INFO_SHORT)
|
||||||
|
state->program = CDP_INFO_LONG;
|
||||||
|
else if (state->program == CDP_INFO_LONG) {
|
||||||
|
if (nanosec_buffer_size > 0)
|
||||||
|
state->program = CDP_INFO_NANOSEC;
|
||||||
|
else
|
||||||
|
state->program = CDP_SCALE;
|
||||||
|
} else if (state->program == CDP_INFO_NANOSEC)
|
||||||
|
state->program = CDP_SCALE;
|
||||||
|
_cdf_update_lcd(state);
|
||||||
|
}
|
||||||
|
// If chirping: stoppit
|
||||||
|
else if (state->mode == CDM_CHIRPING) {
|
||||||
|
_cdf_quit_chirping(state);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EVENT_ALARM_LONG_PRESS:
|
||||||
|
// If in choose mode: start chirping
|
||||||
|
if (state->mode == CDM_CHOOSE) {
|
||||||
|
_cdm_setup_chirp(state);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EVENT_TICK:
|
||||||
|
if (state->mode == CDM_CHIRPING) {
|
||||||
|
++state->tick_state.tick_count;
|
||||||
|
if (state->tick_state.tick_count == state->tick_state.tick_compare) {
|
||||||
|
state->tick_state.tick_count = 0;
|
||||||
|
state->tick_state.tick_fun(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EVENT_TIMEOUT:
|
||||||
|
// Do not time out while we're chirping
|
||||||
|
if (state->mode != CDM_CHIRPING) {
|
||||||
|
movement_move_to_face(0);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return true if the watch can enter standby mode. False needed when chirping.
|
||||||
|
if (state->mode == CDM_CHIRPING)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void chirpy_demo_face_resign(movement_settings_t *settings, void *context) {
|
||||||
|
(void)settings;
|
||||||
|
(void)context;
|
||||||
|
|
||||||
|
if (nanosec_buffer != 0) {
|
||||||
|
free(nanosec_buffer);
|
||||||
|
nanosec_buffer = 0;
|
||||||
|
nanosec_buffer_size = 0;
|
||||||
|
}
|
||||||
|
}
|
70
movement/watch_faces/demo/chirpy_demo_face.h
Normal file
70
movement/watch_faces/demo/chirpy_demo_face.h
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 <#author_name#>
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CHIRPY_DEMO_FACE_H_
|
||||||
|
#define CHIRPY_DEMO_FACE_H_
|
||||||
|
|
||||||
|
#include "movement.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CHIRPY DEMO FACE
|
||||||
|
*
|
||||||
|
* This face demonstrates the chirpy-tx library. It is intended to help you
|
||||||
|
* include chirpy-tx in your own watch faces that need to transmit data out
|
||||||
|
* of the watch.
|
||||||
|
*
|
||||||
|
* The face's first screen lets you select from a few built-in transmissions:
|
||||||
|
*
|
||||||
|
* SCALE cycles through frequencies in fixed increments. This is intended to
|
||||||
|
* collect and analyze audio samples from different watches. With this info
|
||||||
|
* it may be possible to improve chirpy-tx's parameters like the frequencies
|
||||||
|
* it uses to make the method more robust.
|
||||||
|
*
|
||||||
|
* SHORT is a small transmission that contains data taked from the activity_face.
|
||||||
|
*
|
||||||
|
* LONG is a longer transmission that contains the first two strophes of a
|
||||||
|
* famous sea shanty.
|
||||||
|
*
|
||||||
|
* Select the transmission you want with ALARM, the press LONG ALARM to chirp.
|
||||||
|
*
|
||||||
|
* To record and decode a chirpy transmission on your computer, you can use the web app here:
|
||||||
|
* https://jealousmarkup.xyz/off/chirpy/rx/
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
void chirpy_demo_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||||
|
void chirpy_demo_face_activate(movement_settings_t *settings, void *context);
|
||||||
|
bool chirpy_demo_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
|
||||||
|
void chirpy_demo_face_resign(movement_settings_t *settings, void *context);
|
||||||
|
|
||||||
|
#define chirpy_demo_face ((const watch_face_t){ \
|
||||||
|
chirpy_demo_face_setup, \
|
||||||
|
chirpy_demo_face_activate, \
|
||||||
|
chirpy_demo_face_loop, \
|
||||||
|
chirpy_demo_face_resign, \
|
||||||
|
NULL, \
|
||||||
|
})
|
||||||
|
|
||||||
|
#endif // CHIRPY_DEMO_FACE_H_
|
||||||
|
|
Loading…
Reference in a new issue