// Host test: pack a preset and a select with envelope.c and print hex #include #include "../main/envelope.h" static void hex(const uint8_t *b, size_t n) { for (size_t i = 0; i < n; i++) printf("%02x", b[i]); printf("\n"); } int main(void) { const char *json = "{\"p\":\"chase\",\"c\":[\"#ff0000\",\"#0f8\"],\"d\":120,\"b\":200,\"a\":false,\"n1\":5,\"n2\":-3,\"n3\":0,\"n4\":7,\"n5\":0,\"n6\":300}"; const char *json2 = "{\"pattern\":\"on\",\"colors\":[\"#102030\"],\"delay\":0,\"brightness\":0,\"auto\":true}"; cJSON *p = cJSON_Parse(json), *p2 = cJSON_Parse(json2); env_blob_t pb, sb; uint8_t out[256]; env_blob_init(&pb); env_blob_init(&sb); env_add_preset(&pb, "7", p); env_add_preset(&pb, "8", p2); env_add_select(&sb, "mirror", "7", -1); env_add_select(&sb, "roof", "8", 12); hex(out, env_frame(out, 128, &pb, NULL)); hex(out, env_frame(out, -1, NULL, &sb)); return 0; }