{
if (index < handle->number) {
uint8_t *ptr = &(handle->pixels[index * 4]);
- red = ptr + R_OFF_SET;
- green = ptr + G_OFF_SET;
- blue = ptr + B_OFF_SET;
+ *red = ptr[R_OFF_SET];
+ *green = ptr[G_OFF_SET];
+ *blue = ptr[B_OFF_SET];
}
}
HL_UI_LED_Set_Pixel_4byte(HL_UI_LED *handle, uint32_t index, uint32_t colour)
{
uint8_t r, g, b;
- r = colour >> 16;
- g = colour >> 8;
- b = colour;
+ uint8_t *ptr = (uint8_t *)&colour;
+ r = ptr[R_OFF_SET];
+ g = ptr[G_OFF_SET];
+ b = ptr[B_OFF_SET];
HL_UI_LED_Set_Pixel_RGB(handle, index, r, g, b);
}
{
uint8_t r=0, g=0, b=0;
uint32_t colour = 0;
+ uint8_t *ptr = (uint8_t *)&colour;
HL_UI_LED_Get_Pixel_RGB(handle, index, &r, &g, &b);
- r <<= 16;
- g <<= 8;
- colour = r | g | b;
+ ptr[R_OFF_SET] = r;
+ ptr[G_OFF_SET] = g;
+ ptr[B_OFF_SET] = b;
return colour;
}
--- /dev/null
+/*
+* Copyright © 2018 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* 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 (including the next
+* paragraph) 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <tbm_bufmgr.h>
+#include <wayland-tbm-server.h>
+#include <pepper-output-backend.h>
+#include "HL_UI_LED.h"
+#include "output_internal.h"
+
+typedef struct {
+ HL_UI_LED *led;
+
+ struct wl_event_source *source;
+ uint32_t serial;
+ int index;
+} boot_ani_t;
+
+#define ANI_INTERVAL 40 //20ms
+
+static int
+boot_ani_timer_cb(void *data)
+{
+ boot_ani_t *ani = (boot_ani_t *)data;
+ uint8_t r,g,b;
+ uint32_t color;
+
+ if (ani->index == 0) {
+ r = (uint8_t)(rand()%0xFF);
+ g = (uint8_t)(rand()%0xFF);
+ b = (uint8_t)(rand()%0xFF);
+ HL_UI_LED_Set_Pixel_RGB(ani->led, ani->index, r, g, b);
+ } else {
+ color = HL_UI_LED_Get_Pixel_4byte(ani->led, ani->index - 1);
+ HL_UI_LED_Set_Pixel_4byte(ani->led, ani->index, color);
+ }
+
+ HL_UI_LED_Refresh(ani->led);
+
+ ani->serial++;
+ ani->index = (ani->serial)%12;
+
+ wl_event_source_timer_update(ani->source, ANI_INTERVAL);
+
+ return 1;
+}
+
+void boot_ani_start(led_output_t *output)
+{
+ struct wl_event_loop *loop;
+ boot_ani_t *ani;
+ int ret;
+
+ PEPPER_TRACE("[OUTPUT] start boot-animation\n");
+
+ loop = wl_display_get_event_loop(pepper_compositor_get_display(output->compositor));
+ PEPPER_CHECK(loop, return, "failed to wl_display_get_event_loop()\n");
+
+ ani = (boot_ani_t *)calloc(sizeof(boot_ani_t), 1);
+ PEPPER_CHECK(ani, return, "failed to alloc\n");
+
+ ani->source = wl_event_loop_add_timer(loop, boot_ani_timer_cb, ani);
+ PEPPER_CHECK(ani, goto err, "failed to wl_event_loop_add_timer()\n");
+
+ ret = wl_event_source_timer_update(ani->source, ANI_INTERVAL);
+ PEPPER_CHECK(!ret, goto err, "failed to wl_event_source_timer_update\n");
+
+ ani->led = output->ui_led;
+ output->boot_ani = ani;
+ return;
+err:
+ if (ani) {
+ if (ani->source)
+ wl_event_source_remove(ani->source);
+
+ free(ani);
+ }
+ return;
+}
+
+void boot_ani_stop(led_output_t *output)
+{
+ boot_ani_t *ani;
+
+ if (!output->boot_ani) return;
+
+ ani = (boot_ani_t *)output->boot_ani;
+
+ HL_UI_LED_Clear_All(ani->led);
+ wl_event_source_remove(ani->source);
+ free(ani);
+
+ output->boot_ani = NULL;
+ return;
+}
--- /dev/null
+/*
+* Copyright © 2018 Samsung Electronics co., Ltd. All Rights Reserved.
+*
+* 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 (including the next
+* paragraph) 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <pepper-output-backend.h>
+
+#define NUM_LED 12
+
+typedef struct {
+ pepper_compositor_t *compositor;
+ pepper_output_t *output;
+ pepper_plane_t *plane;
+
+ int num_led;
+ HL_UI_LED *ui_led;
+
+ struct wayland_tbm_server *tbm_server;
+ struct wl_event_source *frame_done;
+
+ pepper_view_t *top_view;
+
+ //For booting animation
+ void *boot_ani;
+}led_output_t;
+
+PEPPER_API void boot_ani_start(led_output_t *output);
+PEPPER_API void boot_ani_stop(led_output_t *output);
\ No newline at end of file
#include <wayland-tbm-server.h>
#include <pepper-output-backend.h>
#include "HL_UI_LED.h"
-
-#define NUM_LED 12
-
-typedef struct {
- pepper_compositor_t *compositor;
- pepper_output_t *output;
- pepper_plane_t *plane;
-
- int num_led;
- HL_UI_LED *ui_led;
-
- struct wayland_tbm_server *tbm_server;
- struct wl_event_source *frame_done;
-
- pepper_view_t *top_view;
-}led_output_t;
+#include "output_internal.h"
static const int KEY_OUTPUT;
static void led_output_add_frame_done(led_output_t *output);
output->ui_led = HL_UI_LED_Init(output->num_led);
if (!output->ui_led)
PEPPER_ERROR("HL_UI_LED_Init() failed.\n");
+ else
+ boot_ani_start(output);
output->output = pepper_compositor_add_output(compositor,
&led_output_backend, "led_output",