Skip to content

Commit 1cdc70d

Browse files
committed
Initial Commit
0 parents  commit 1cdc70d

19 files changed

+1777
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
sdkconfig.old
2+
.DS_Store
3+
components/arduino/
4+
components/esp-face/
5+
components/esp32-camera/
6+
out/
7+
build/
8+
xtensa-esp32-elf/

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
PROJECT_NAME := esp32-arduino-lib-builder
2+
3+
EXTRA_COMPONENT_DIRS += $(PROJECT_PATH)/components/esp-face/lib
4+
EXTRA_COMPONENT_DIRS += $(PROJECT_PATH)/components/esp-face/image_util
5+
EXTRA_COMPONENT_DIRS += $(PROJECT_PATH)/components/esp-face/face_detection
6+
EXTRA_COMPONENT_DIRS += $(PROJECT_PATH)/components/esp-face/face_recognition
7+
8+
include $(IDF_PATH)/make/project.mk
9+
10+
IDF_INCLUDES = $(filter-out $(PROJECT_PATH)/%,$(COMPONENT_INCLUDES))
11+
IDF_OUT = $(patsubst $(IDF_PATH)/components/%,%,$(IDF_INCLUDES))
12+
13+
PROJ_INCLUDES = $(filter-out $(PROJECT_PATH)/components/arduino/%,$(filter $(PROJECT_PATH)/components/%, $(COMPONENT_INCLUDES)))
14+
PROJ_OUT = $(patsubst $(PROJECT_PATH)/components/%,%,$(PROJ_INCLUDES))
15+
16+
idf-libs: all
17+
@$(PROJECT_PATH)/tools/prepare-libs.sh $(IDF_OUT) $(PROJ_OUT)

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#ESP32 Arduino Lib Builder
2+
3+
This repository contains the scripts that produce the libraries included with esp32-arduino.

build.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
if ! [ -x "$(command -v make)" ]; then
4+
echo "ERROR: Make is not installed! Please install Make first."
5+
exit 1
6+
fi
7+
8+
#install esp-idf and gcc toolchain
9+
source ./tools/install-esp-idf.sh
10+
11+
#update components from git
12+
./tools/update-components.sh
13+
14+
#build and prepare libs
15+
./tools/build-libs.sh
16+
17+
#bootloader
18+
./tools/build-bootloaders.sh
19+
20+
#POST Build
21+
#./tools/copy-to-arduino.sh

components/fb_gfx/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set(COMPONENT_SRCS "fb_gfx.c")
2+
set(COMPONENT_ADD_INCLUDEDIRS "include")
3+
set(COMPONENT_PRIV_INCLUDEDIRS "")
4+
set(COMPONENT_PRIV_REQUIRES newlib)
5+
register_component()

components/fb_gfx/FreeMonoBold12pt7b.h

Lines changed: 250 additions & 0 deletions
Large diffs are not rendered by default.

components/fb_gfx/component.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
COMPONENT_ADD_INCLUDEDIRS := include
2+
COMPONENT_SRCDIRS := .

components/fb_gfx/fb_gfx.c

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
#include "stdint.h"
15+
#include "stdarg.h"
16+
#include "string.h"
17+
#include "stdio.h"
18+
#include "stdlib.h"
19+
#include "fb_gfx.h"
20+
21+
typedef struct { // Data stored PER GLYPH
22+
uint16_t bitmapOffset; // Pointer into GFXfont->bitmap
23+
uint8_t width, height; // Bitmap dimensions in pixels
24+
uint8_t xAdvance; // Distance to advance cursor (x axis)
25+
int8_t xOffset, yOffset; // Dist from cursor pos to UL corner
26+
} GFXglyph;
27+
28+
typedef struct { // Data stored for FONT AS A WHOLE:
29+
uint8_t *bitmap; // Glyph bitmaps, concatenated
30+
GFXglyph *glyph; // Glyph array
31+
uint8_t first, last; // ASCII extents
32+
uint8_t yAdvance; // Newline distance (y axis)
33+
uint8_t yOffset; // Y offset of the font zero line (y axis)
34+
} GFXfont;
35+
36+
#include "FreeMonoBold12pt7b.h"//14x24
37+
#define gfxFont ((GFXfont*)(&FreeMonoBold12pt7b))
38+
39+
void fb_gfx_fillRect(fb_data_t *fb, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color)
40+
{
41+
int32_t line_step = (fb->width - w) * 3;
42+
uint8_t *data = fb->data + ((x + (y * fb->width)) * 3);
43+
uint8_t c0 = color >> 16;
44+
uint8_t c1 = color >> 8;
45+
uint8_t c2 = color;
46+
for (int i=0; i<h; i++){
47+
for (int j=0; j<w; j++){
48+
data[0] = c0;
49+
data[1] = c1;
50+
data[2] = c2;
51+
data+=3;
52+
}
53+
data += line_step;
54+
}
55+
}
56+
57+
void fb_gfx_drawFastHLine(fb_data_t *fb, int32_t x, int32_t y, int32_t w, uint32_t color)
58+
{
59+
fb_gfx_fillRect(fb, x, y, w, 1, color);
60+
}
61+
62+
void fb_gfx_drawFastVLine(fb_data_t *fb, int32_t x, int32_t y, int32_t h, uint32_t color)
63+
{
64+
fb_gfx_fillRect(fb, x, y, 1, h, color);
65+
}
66+
67+
uint8_t fb_gfx_putc(fb_data_t *fb, int32_t x, int32_t y, uint32_t color, unsigned char c)
68+
{
69+
uint16_t line_width;
70+
uint8_t xa = 0, bit = 0, bits = 0, xx, yy;
71+
uint8_t *bitmap;
72+
GFXglyph *glyph;
73+
74+
if ((c < 32) || (c < gfxFont->first) || (c > gfxFont->last)) {
75+
return xa;
76+
}
77+
78+
c -= gfxFont->first;
79+
80+
glyph = &(gfxFont->glyph[c]);
81+
bitmap = gfxFont->bitmap + glyph->bitmapOffset;
82+
83+
xa = glyph->xAdvance;
84+
x += glyph->xOffset;
85+
y += glyph->yOffset;
86+
y += gfxFont->yOffset;
87+
line_width = 0;
88+
89+
for(yy=0; yy<glyph->height; yy++) {
90+
for(xx=0; xx<glyph->width; xx++) {
91+
if(bit == 0) {
92+
bits = *bitmap++;
93+
bit = 0x80;
94+
}
95+
if(bits & bit) {
96+
line_width++;
97+
} else if (line_width) {
98+
fb_gfx_drawFastHLine(fb, x+xx-line_width, y+yy, line_width, color);
99+
line_width=0;
100+
}
101+
bit >>= 1;
102+
}
103+
if (line_width) {
104+
fb_gfx_drawFastHLine(fb, x+xx-line_width, y+yy, line_width, color);
105+
line_width=0;
106+
}
107+
}
108+
return xa;
109+
}
110+
111+
uint32_t fb_gfx_print(fb_data_t *fb, int x, int y, uint32_t color, const char * str)
112+
{
113+
uint32_t l = 0;
114+
int xc = x, yc = y, lc = fb->width - gfxFont->glyph[0].xAdvance;
115+
uint8_t fh = gfxFont->yAdvance;
116+
char c = *str++;
117+
while(c){
118+
if(c != '\r'){
119+
if(c == '\n'){
120+
yc += fh;
121+
xc = x;
122+
} else {
123+
if(xc > lc){
124+
yc += fh;
125+
xc = x;
126+
}
127+
xc += fb_gfx_putc(fb, xc, yc, color, c);
128+
}
129+
}
130+
l++;
131+
c = *str++;
132+
}
133+
return l;
134+
}
135+
136+
uint32_t fb_gfx_printf(fb_data_t *fb, int32_t x, int32_t y, uint32_t color, const char *format, ...)
137+
{
138+
char loc_buf[64];
139+
char * temp = loc_buf;
140+
int len;
141+
va_list arg;
142+
va_list copy;
143+
va_start(arg, format);
144+
va_copy(copy, arg);
145+
len = vsnprintf(loc_buf, sizeof(loc_buf), format, arg);
146+
va_end(copy);
147+
if(len >= sizeof(loc_buf)){
148+
temp = (char*)malloc(len+1);
149+
if(temp == NULL) {
150+
return 0;
151+
}
152+
}
153+
vsnprintf(temp, len+1, format, arg);
154+
va_end(arg);
155+
fb_gfx_print(fb, x, y, color, temp);
156+
if(len > 64){
157+
free(temp);
158+
}
159+
return len;
160+
}

components/fb_gfx/include/fb_gfx.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
#ifndef _FB_GFX_H_
15+
#define _FB_GFX_H_
16+
17+
#ifdef __cplusplus
18+
extern "C" {
19+
#endif
20+
21+
typedef enum {
22+
FB_RGB888, FB_BGR888, FB_RGB565, FB_BGR565
23+
} fb_format_t;
24+
25+
typedef struct {
26+
int width;
27+
int height;
28+
int bytes_per_pixel;
29+
fb_format_t format;
30+
uint8_t * data;
31+
} fb_data_t;
32+
33+
void fb_gfx_fillRect (fb_data_t *fb, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color);
34+
void fb_gfx_drawFastHLine(fb_data_t *fb, int32_t x, int32_t y, int32_t w, uint32_t color);
35+
void fb_gfx_drawFastVLine(fb_data_t *fb, int32_t x, int32_t y, int32_t h, uint32_t color);
36+
uint8_t fb_gfx_putc (fb_data_t *fb, int32_t x, int32_t y, uint32_t color, unsigned char c);
37+
uint32_t fb_gfx_print (fb_data_t *fb, int32_t x, int32_t y, uint32_t color, const char * str);
38+
uint32_t fb_gfx_printf (fb_data_t *fb, int32_t x, int32_t y, uint32_t color, const char *format, ...);
39+
40+
#ifdef __cplusplus
41+
}
42+
#endif
43+
44+
#endif /* _FB_GFX_H_ */

main/component.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CXXFLAGS += -fno-rtti

main/sketch.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "Arduino.h"
2+
3+
void setup(){
4+
5+
}
6+
7+
void loop(){
8+
9+
}

0 commit comments

Comments
 (0)