#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <stdint.h>
#include <string.h>
#include <linux/fb.h>
#include <sys/ioctl.h>
#include "midas.h"
Go to the source code of this file.
|
| #define | FILESIZE (64 * sizeof(uint16_t)) |
| |
◆ FILESIZE
| #define FILESIZE (64 * sizeof(uint16_t)) |
◆ rpi_led()
Definition at line 143 of file rpi_led.c.
144{
145 va_list argptr;
148 float *pvalue;
151
152 va_start(argptr, cmd);
154
155 switch (cmd) {
158 info = va_arg(argptr,
void *);
160 break;
161
163 info = va_arg(argptr,
void *);
165 break;
166
168 info = va_arg(argptr,
void *);
170 value = va_arg(argptr,
double);
172 break;
173
175 info = va_arg(argptr,
void *);
177 pvalue = va_arg(argptr, float *);
179 break;
180
181 default:
182 break;
183 }
184
185 va_end(argptr);
186
188}
INT rpi_led_init(HNDLE hkey, void **pinfo)
INT rpi_led_exit(RPI_LED_INFO *info)
INT rpi_led_set(RPI_LED_INFO *info, INT channel, double value)
INT rpi_led_get(RPI_LED_INFO *info, INT channel, float *pvalue)
◆ rpi_led_exit()
Definition at line 90 of file rpi_led.c.
91{
92
94 perror("Error un-mmapping the file");
95 }
97
98
100
102}
◆ rpi_led_get()
Definition at line 124 of file rpi_led.c.
125{
126 uint16_t r, g, b, rgb;
127 uint32_t col;
128
129
131 r = (rgb >> 11) & 0x1F;
132 g = (rgb >> 6) & 0x1F;
133 b = (rgb >> 1) & 0x1F;
134
135 col = (r << 16) | (g << 8) | b;
136 *pvalue = (float) col;
137
139}
◆ rpi_led_init()
| INT rpi_led_init |
( |
HNDLE |
hkey, |
|
|
void ** |
pinfo |
|
) |
| |
Definition at line 44 of file rpi_led.c.
45{
47 struct fb_fix_screeninfo fix_info;
48
49
52
53
54 info->fbfd = open(
"/dev/fb1", O_RDWR);
55 if (
info->fbfd == -1) {
56 perror("Error (call to 'open')");
57 exit(EXIT_FAILURE);
58 }
59
60
61 if (ioctl(
info->fbfd, FBIOGET_FSCREENINFO, &fix_info) == -1) {
62 perror("Error (call to 'ioctl')");
64 exit(EXIT_FAILURE);
65 }
66
67
68 if (strcmp(fix_info.id, "RPi-Sense FB") != 0) {
69 printf("Error: RPi-Sense FB not found\n");
71 exit(EXIT_FAILURE);
72 }
73
74
75 info->map = mmap(NULL,
FILESIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
info->fbfd, 0);
76 if (
info->map == MAP_FAILED) {
78 perror("Error mmapping the file");
79 exit(EXIT_FAILURE);
80 }
81
82
84
86}
◆ rpi_led_set()
Definition at line 106 of file rpi_led.c.
107{
108 uint16_t r, g, b, rgb;
109 uint32_t col;
110
111 col = (uint32_t)
value;
112
113 r = ((col >> 16) & 0xFF) >> 3;
114 g = ((col >> 8) & 0xFF) >> 3;
115 b = ((col >> 0) & 0xFF) >> 3;
116 rgb = (r << 11) | (g << 6) | (b << 1);
118
120}