68#define ARGUS_PIXELS_X 8
73#define ARGUS_PIXELS_Y 4
78#define ARGUS_PIXELS ((ARGUS_PIXELS_X)*(ARGUS_PIXELS_Y))
87#define PIXEL_XY2CH(x, y) ((((y) << 3U) & 0x10U) | (((x) ^ 0x07U) << 1U) | ((y) & 0x01U))
94#define PIXEL_CH2X(c) ((((c) >> 1U) ^ 0x07U) & 0x07U)
101#define PIXEL_CH2Y(c) ((((c) >> 3U) & 0x02U) | ((c) & 0x01U))
110#define PIXEL_XY2N(x, y) (((x) << 2U) | (y))
117#define PIXEL_N2X(n) ((n) >> 2U)
124#define PIXEL_N2Y(n) ((n) & 0x03U)
132#define PIXEL_N2CH(n) ((((n) << 3U) & 0x10U) | ((((n) >> 1U) ^ 0x0EU) & 0x0EU) | ((n) & 0x01U))
139#define PIXEL_CH2N(c) (((((c) << 1U) ^ 0x1CU) & 0x1CU) | (((c) >> 3U) & 0x02U) | ((c) & 0x01U))
147#define PIXELN_MASK(n) (0x01U << (n))
155#define PIXELN_ISENABLED(msk, n) (((msk) >> (n)) & 0x01U)
162#define PIXELN_ENABLE(msk, n) ((msk) |= (PIXELN_MASK(n)))
169#define PIXELN_DISABLE(msk, n) ((msk) &= (~PIXELN_MASK(n)))
177#define PIXELCH_MASK(c) (0x01U << (PIXEL_CH2N(c)))
185#define PIXELCH_ISENABLED(msk, c) (PIXELN_ISENABLED(msk, PIXEL_CH2N(c)))
192#define PIXELCH_ENABLE(msk, c) (PIXELN_ENABLE(msk, PIXEL_CH2N(c)))
199#define PIXELCH_DISABLE(msk, c) (PIXELN_DISABLE(msk, PIXEL_CH2N(c)))
208#define PIXELXY_MASK(x, y) (0x01U << (PIXEL_XY2N(x, y)))
217#define PIXELXY_ISENABLED(msk, x, y) (PIXELN_ISENABLED(msk, PIXEL_XY2N(x, y)))
225#define PIXELXY_ENABLE(msk, x, y) (PIXELN_ENABLE(msk, PIXEL_XY2N(x, y)))
233#define PIXELXY_DISABLE(msk, x, y) (PIXELN_DISABLE(msk, PIXEL_XY2N(x, y)))
242#define CHANNELN_ISENABLED(msk, ch) (((msk) >> ((ch) - 32U)) & 0x01U)
249#define CHANNELN_ENABLE(msk, ch) ((msk) |= (0x01U << ((ch) - 32U)))
256#define CHANNELN_DISABLE(msk, ch) ((msk) &= (~(0x01U << ((ch) - 32U))))
265#define PIXEL_COUNT(pxmsk) popcount(pxmsk)
274#define CHANNEL_COUNT(pxmsk, chmsk) (popcount(pxmsk) + popcount(chmsk))
284 for (uint_fast8_t n = 0; n < 32; n += 2)
299 for (uint_fast8_t ch = 0; ch < 32; ch += 2)
301 res |= ((msk >>
PIXEL_CH2N(ch)) & 0x3U) << ch;
355 const uint8_t center_y)
357 if (dx == 0 && dy == 0)
return pixel_mask;
359 uint32_t shifted_mask = 0;
365 int8_t x_src = (int8_t)(x - dx);
366 int8_t y_src = (int8_t)(y - dy);
371 if ((center_y & 0x1) && (y & 0x1))
375 if (!(center_y & 0x1) && !(y & 0x1))
418 const uint8_t pixel_count,
419 const uint8_t center_x,
420 const uint8_t center_y)
433 int32_t min_dist = INT32_MAX;
444 int32_t distx = (x - center_x) << 1;
445 if (!(y & 0x1)) distx++;
446 if (!(center_y & 0x1)) distx--;
448 const int32_t disty = (y - center_y) << 1;
449 int32_t dist = distx * distx + disty * disty;
484 const uint_fast8_t y)
491 bool isXEdgeLow = (x == 0);
493 bool isYEdgeLow = (y == 0);
499 if ((!isXEdgeHigh) && (!isYEdgeLow))
PIXELXY_ENABLE(mask, x + 1, y - 1);
501 if ((!isXEdgeHigh) && (!isYEdgeHigh))
PIXELXY_ENABLE(mask, x + 1, y + 1);
507 if ((!isXEdgeLow) && (!isYEdgeLow))
PIXELXY_ENABLE(mask, x - 1, y - 1);
511 if ((!isXEdgeLow) && (!isYEdgeHigh))
PIXELXY_ENABLE(mask, x - 1, y + 1);
static uint32_t PixelToChannelMask(uint32_t msk)
Converts a x-y-sorted pixel mask to a raw ADC channel mask.
Definition argus_map.h:296
#define ARGUS_PIXELS_Y
The device pixel field size in y direction (short edge).
Definition argus_map.h:73
static uint32_t GetAdjacentPixelsMask(const uint_fast8_t x, const uint_fast8_t y)
Fills a pixel mask with the direct neighboring pixels around a pixel.
Definition argus_map.h:483
#define PIXEL_CH2N(c)
Macro to determine the pixel.
Definition argus_map.h:139
static uint32_t ShiftSelectedPixels(const uint32_t pixel_mask, const int8_t dx, const int8_t dy, const uint8_t center_y)
Shifts a pixel mask by a given offset.
Definition argus_map.h:352
static uint32_t FillPixelMask(uint32_t pixel_mask, const uint8_t pixel_count, const uint8_t center_x, const uint8_t center_y)
Fills a pixel mask to a specified number of pixels around a center pixel.
Definition argus_map.h:417
static uint32_t ChannelToPixelMask(uint32_t msk)
Converts a raw ADC channel mask to a x-y-sorted pixel mask.
Definition argus_map.h:281
#define ARGUS_PIXELS_X
The device pixel field size in x direction (long edge).
Definition argus_map.h:68
#define PIXELXY_ISENABLED(msk, x, y)
Macro to determine if a pixel given by the x-y-indices is enabled in a pixel mask.
Definition argus_map.h:217
#define PIXEL_N2CH(n)
Macro to determine the pixel n-index from the ADC channel number.
Definition argus_map.h:132
#define ARGUS_PIXELS
The total device pixel count.
Definition argus_map.h:78
#define PIXELXY_ENABLE(msk, x, y)
Macro to enable a pixel given by the x-y-indices in a pixel mask.
Definition argus_map.h:225
#define PIXEL_COUNT(pxmsk)
Macro to determine the number of enabled pixel/channels in a mask via a popcount algorithm.
Definition argus_map.h:265
This file is part of the AFBR-S50 API.