removed unused files from snake lib
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
AVR utils library
|
||||
=================
|
||||
|
||||
This is my ever-evolving library (not only) for AVR programming.
|
||||
|
||||
When I'm done with a project, I copy the current library to the project, so it doesn't break when I do further improvements.
|
||||
|
||||
Each library file contains a large comment block explaining it's function.
|
||||
@@ -1,83 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
Some useful utilities for RGB color manipulation
|
||||
|
||||
The XXXc macros don't use cast, so they can be used in array initializers.
|
||||
|
||||
xrgb ... 3-byte true-color RGB (8 bits per component)
|
||||
rgbXX ... XX-bit color value, with equal nr of bits per component
|
||||
|
||||
XX_r (_g, _b) ... extract component from the color, and convert it to 0..255
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
} xrgb_t;
|
||||
|
||||
typedef uint32_t rgb24_t;
|
||||
typedef uint16_t rgb16_t;
|
||||
typedef uint16_t rgb12_t;
|
||||
typedef uint8_t rgb6_t;
|
||||
|
||||
|
||||
#define xrgb(rr, gg, bb) ((xrgb_t)xrgbc(rr, gg, bb))
|
||||
// xrgb for constant array declarations
|
||||
#define xrgbc(rr, gg, bb) { .r = ((uint8_t)(rr)), .g = ((uint8_t)(gg)), .b = ((uint8_t)(bb)) }
|
||||
#define xrgb_r(c) ((uint8_t)(c.r))
|
||||
#define xrgb_g(c) ((uint8_t)(c.g))
|
||||
#define xrgb_b(c) ((uint8_t)(c.b))
|
||||
#define xrgb_rgb24(c) ((((rgb24_t)c.r) << 16) | (((rgb24_t)c.g) << 8) | (((rgb24_t)c.b)))
|
||||
#define xrgb_rgb15(c) (((((rgb15_t)c.r) & 0xF8) << 7) | ((((rgb15_t)c.g) & 0xF8) << 2) | ((((rgb15_t)c.b) & 0xF8) >> 3))
|
||||
#define xrgb_rgb12(c) (((((rgb12_t)c.r) & 0xF0) << 4) | ((((rgb12_t)c.g) & 0xF0)) | ((((rgb12_t)c.b) & 0xF0) >> 4))
|
||||
#define xrgb_rgb6(c) (((((rgb6_t)c.r) & 0xC0) >> 2) | ((((rgb6_t)c.g) & 0xC0) >> 4) | ((((rgb6_t)c.b) & 0xC0) >> 6))
|
||||
|
||||
|
||||
#define rgb24c(r,g,b) (((((rgb24_t)r) & 0xFF) << 16) | ((((rgb24_t)g) & 0xFF) << 8) | (((rgb24_t)b) & 0xFF))
|
||||
#define rgb24(r,g,b) ((rgb24_t) rgb24(r,g,b))
|
||||
|
||||
#define rgb24_r(c) ((((rgb24_t) (c)) >> 16) & 0xFF)
|
||||
#define rgb24_g(c) ((((rgb24_t) (c)) >> 8) & 0xFF)
|
||||
#define rgb24_b(c) ((((rgb24_t) (c)) >> 0) & 0xFF)
|
||||
#define rgb24_xrgb(c) xrgb(rgb24_r(c), rgb24_g(c), rgb24_b(c))
|
||||
#define rgb24_xrgbc(c) xrgbc(rgb24_r(c), rgb24_g(c), rgb24_b(c))
|
||||
|
||||
|
||||
#define rgb15(r,g,b) ((rgb16_t) rgb15c(r,g,b))
|
||||
#define rgb15c(r,g,b) (((r & 0x1F) << 10) | ((g & 0x1F) << 5) | (b & 0x1F))
|
||||
|
||||
#define rgb15_r(c) ((((rgb15_t) (c)) & 0x7C00) >> 7)
|
||||
#define rgb15_g(c) ((((rgb15_t) (c)) & 0x3E0) >> 2)
|
||||
#define rgb15_b(c) ((((rgb15_t) (c)) & 0x1F) << 3)
|
||||
#define rgb15_xrgb(c) xrgb(rgb15_r(c), rgb15_g(c), rgb15_b(c))
|
||||
#define rgb15_rgb24(c) rgb24(rgb15_r(c), rgb15_g(c), rgb15_b(c))
|
||||
#define rgb15_rgb24c(c) rgb24c(rgb15_r(c), rgb15_g(c), rgb15_b(c))
|
||||
|
||||
|
||||
#define rgb12(r,g,b) ((rgb12_t) rgb12c(r,g,b))
|
||||
#define rgb12c(r,g,b) (((r & 0xF) << 8) | ((g & 0xF) << 4) | (b & 0xF))
|
||||
|
||||
#define rgb12_r(c) ((((rgb12_t) (c)) & 0xF00) >> 4)
|
||||
#define rgb12_g(c) (((rgb12_t) (c)) & 0xF0)
|
||||
#define rgb12_b(c) (((r(rgb12_t) (c)gb) & 0x0F) << 4)
|
||||
#define rgb12_xrgb(c) xrgb(rgb12_r(c), rgb12_g(c), rgb12_b(c))
|
||||
#define rgb12_xrgbc(c) xrgbc(rgb12_r(c), rgb12_g(c), rgb12_b(c))
|
||||
#define rgb12_rgb24(c) rgb24(rgb12_r(c), rgb12_g(c), rgb12_b(c))
|
||||
#define rgb12_rgb24c(c) rgb24c(rgb12_r(c), rgb12_g(c), rgb12_b(c))
|
||||
|
||||
|
||||
#define rgb6(r,g,b) ((rgb6_t) rgb6c(r,g,b))
|
||||
#define rgb6c(r,g,b) (((r & 3) << 4) | ((g & 3) << 2) | (b & 3))
|
||||
|
||||
#define rgb6_r(c) ((((rgb6_t) (c)) & 0x30) << 2)
|
||||
#define rgb6_g(c) ((((rgb6_t) (c)) & 0xC) << 4)
|
||||
#define rgb6_b(c) ((((rgb6_t) (c)) & 0x3) << 6)
|
||||
#define rgb6_xrgb(c) xrgb(rgb6_r(c), rgb6_g(c), rgb6_b(c))
|
||||
#define rgb6_xrgbc(c) xrgbc(rgb6_r(c), rgb6_g(c), rgb6_b(c))
|
||||
#define rgb6_rgb24(c) rgb24(rgb6_r(c), rgb6_g(c), rgb6_b(c))
|
||||
#define rgb6_rgb24c(c) rgb24c(rgb6_r(c), rgb6_g(c), rgb6_b(c))
|
||||
|
||||
|
||||
#define add_xrgb(x, y) ((xrgb_t) { (((y).r > (255 - (x).r)) ? 255 : ((x).r + (y).r)), (((y).g > (255 - (x).g)) ? 255 : ((x).g + (y).g)), (((y).b > 255 - (x).b) ? 255 : ((x).b + (y).b)) })
|
||||
@@ -1,98 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
Utils for driving a WS28xx (tested on WS2812B) RGB LED strips.
|
||||
|
||||
It's implemented as macros to avoid overhead when passing values, and to
|
||||
enable driving multiple strips at once.
|
||||
|
||||
To avoid bloating your code, try to reduce the number of invocations -
|
||||
compute color and then send it.
|
||||
|
||||
[IMPORTANT]
|
||||
|
||||
Some seemingly random influences can ruin the communication.
|
||||
If you have enough memory, consider preparing the colors in array,
|
||||
and sending this array using one of the "ws_send_XXX_array" macros.
|
||||
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
|
||||
#include "pins.h"
|
||||
#include "nsdelay.h"
|
||||
#include "colors.h"
|
||||
|
||||
/* Driver code for WS2812B */
|
||||
|
||||
// --- timing constraints (NS) ---
|
||||
|
||||
#ifndef WS_T_1H
|
||||
# define WS_T_1H 700
|
||||
#endif
|
||||
|
||||
#ifndef WS_T_1L
|
||||
# define WS_T_1L 150
|
||||
#endif
|
||||
|
||||
#ifndef WS_T_0H
|
||||
# define WS_T_0H 150
|
||||
#endif
|
||||
|
||||
#ifndef WS_T_0L
|
||||
# define WS_T_0L 700
|
||||
#endif
|
||||
|
||||
#ifndef WS_T_LATCH
|
||||
# define WS_T_LATCH 7000
|
||||
#endif
|
||||
|
||||
|
||||
/** Wait long enough for the colors to show */
|
||||
#define ws_show() do {delay_ns_c(WS_T_LATCH, 0); } while(0)
|
||||
|
||||
|
||||
/** Send one byte to the RGB strip */
|
||||
#define ws_send_byte(io, bb) do { \
|
||||
for (volatile int8_t __ws_tmp = 7; __ws_tmp >= 0; --__ws_tmp) { \
|
||||
if ((bb) & (1 << __ws_tmp)) { \
|
||||
pin_high(io_pack(io)); delay_ns_c(WS_T_1H, -2); \
|
||||
pin_low(io_pack(io)); delay_ns_c(WS_T_1L, -10); \
|
||||
} else { \
|
||||
pin_high(io_pack(io)); delay_ns_c(WS_T_0H, -2); \
|
||||
pin_low(io_pack(io)); delay_ns_c(WS_T_0L, -10); \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
/** Send R,G,B color to the strip */
|
||||
#define ws_send_rgb(io, r, g, b) do { \
|
||||
ws_send_byte(io_pack(io), g); \
|
||||
ws_send_byte(io_pack(io), r); \
|
||||
ws_send_byte(io_pack(io), b); \
|
||||
} while(0)
|
||||
|
||||
/** Send a RGB struct */
|
||||
#define ws_send_xrgb(io, xrgb) ws_send_rgb(io_pack(io), (xrgb).r, (xrgb).g, (xrgb).b)
|
||||
|
||||
/** Send color hex */
|
||||
#define ws_send_rgb24(io, rgb) ws_send_rgb(io_pack(io), rgb24_r(rgb), rgb24_g(rgb), rgb24_b(rgb))
|
||||
#define ws_send_rgb15(io, rgb) ws_send_rgb(io_pack(io), rgb15_r(rgb), rgb15_g(rgb), rgb15_b(rgb))
|
||||
#define ws_send_rgb12(io, rgb) ws_send_rgb(io_pack(io), rgb12_r(rgb), rgb12_g(rgb), rgb12_b(rgb))
|
||||
#define ws_send_rgb6(io, rgb) ws_send_rgb(io_pack(io), rgb6_r(rgb), rgb6_g(rgb), rgb6_b(rgb))
|
||||
|
||||
/** Send array of colors */
|
||||
#define ws_send_xrgb_array(io, rgbs, length) __ws_send_array_proto(io_pack(io), (rgbs), (length), xrgb)
|
||||
#define ws_send_rgb24_array(io, rgbs, length) __ws_send_array_proto(io_pack(io), (rgbs), (length), rgb24)
|
||||
#define ws_send_rgb15_array(io, rgbs, length) __ws_send_array_proto(io_pack(io), (rgbs), (length), rgb15)
|
||||
#define ws_send_rgb12_array(io, rgbs, length) __ws_send_array_proto(io_pack(io), (rgbs), (length), rgb12)
|
||||
#define ws_send_rgb6_array(io, rgbs, length) __ws_send_array_proto(io_pack(io), (rgbs), (length), rgb6)
|
||||
|
||||
// prototype for sending array. it's ugly, sorry.
|
||||
#define __ws_send_array_proto(io, rgbs, length, style) do { \
|
||||
for (uint8_t __ws_tmp_sap_i = 0; __ws_tmp_sap_i < length; __ws_tmp_sap_i++) { \
|
||||
style ## _t __ws_tmp_sap2 = (rgbs)[__ws_tmp_sap_i]; \
|
||||
ws_send_ ## style(io_pack(io), __ws_tmp_sap2); \
|
||||
} \
|
||||
} while(0)
|
||||
@@ -1,31 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
Ye Olde Control Structures
|
||||
*/
|
||||
|
||||
#include "loops.h"
|
||||
|
||||
#define whilst(what) while((what))
|
||||
#define when(what) if((what))
|
||||
#define otherwise else
|
||||
#define commence {
|
||||
#define then {
|
||||
#define cease }
|
||||
#define choose(what) switch((what))
|
||||
#define option case
|
||||
#define shatter break
|
||||
#define replay continue
|
||||
#define equals ==
|
||||
#define is ==
|
||||
#define be =
|
||||
#define over >
|
||||
#define above >
|
||||
#define under <
|
||||
#define below <
|
||||
#define let /**/
|
||||
#define raise(what) (what)++
|
||||
|
||||
#define number int
|
||||
|
||||
#warning "This is a joke. Do not use YeOlde.h in serious code!"
|
||||
Reference in New Issue
Block a user