Closed nicoverduin closed 1 year ago
Seems like the linker just wants to add everything into the flash. Now I just made a link to the csrc folder and added the files in my CMakeLists.txt and it compiles fine. Now the programs are reduce to something like 50+ kbytes
My CMakeLists.xt `# @file CmakeLists.txt
set (UCGLIB "../ucglib/csrc/")
cmake_path(GET CMAKE_CURRENT_SOURCE_DIR FILENAME PROJECTNAME) string(REPLACE " " "" ProjectId ${PROJECT_NAME}) project(${PROJECT_NAME})
set(PROJECT_SOURCE_DIRS ".c .h")
if (DEFINED UCGLIB)
set(PROJECT_SOURCE_DIRS ${PROJECT_SOURCE_DIRS} ${UCGLIB}*.c ${UCGLIB}*.h)
# search in folder
include_directories(${UCGLIB})
endif()
file(GLOB PROJECT_SRC CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIRS})
add_executable(${PROJECT_NAME} main.c ${PROJECT_SRC} )
pico_enable_stdio_usb(${PROJECT_NAME} 1) pico_enable_stdio_uart(${PROJECT_NAME} 0)
target_link_libraries(${PROJECT_NAME} pico_stdlib hardware_spi hardware_gpio)
pico_add_extra_outputs(${PROJECT_NAME})
example_auto_set_url(${PROJECT_NAME})
`
I use the Respberry PICO and if I compile ucglib into a static library, I get a file of about 3.6 Megabytes. The if I create a simple project with ucglib I get an elf of 1.168 megabytes. Isn't that a bot large? I have attched the folowing files: a) ucglib_pico.h containing the the callback b) spi_pins.h containing SPI port and pin definitions c) main.c actual program d) CMakeLists.txt for the program e) CMakeLists.txt for the library
ucglib is built into a separate folder
ucglib_pico.h ' /**
// includes
include "hardware/spi.h"
include "hardware/gpio.h"
include "pico/time.h"
include "pico.h"
include "ucg.h" // ucglib interface
include "../../ucg_1/spi_pins.h" // shows the connections of the tft screen to SPI
/**
@return 1 fixed value is returned / int16_t ucg_com_pico_cb(ucg_t ucg, int16_t msg, uint16_t arg, uint8_t data) { switch(msg) { case UCG_COM_MSG_POWER_UP: / "data" is a pointer to ucg_com_info_t structure with the following information: / / ((ucg_com_info_t )data)->serial_clk_speed value in nanoseconds / / ((ucg_com_info_t )data)->parallel_clk_speed value in nanoseconds / / "arg" is not used */
//arg == 1 ? gpio_put(TFT_DC, 1) : gpio_put(TFT_DC, 0); break; case UCG_COM_MSG_CHANGE_CS_LINE: / "ucg->com_status" bit 1 contains the old level for the CS line / / "data" is not used / / "arg" = 1: set the chipselect output line to 1 / / "arg" = 0: set the chipselect output line to 0 / gpio_put(TFT_CS, arg); break; case UCG_COM_MSG_SEND_BYTE: / "data" is not used / / "arg" contains one byte, which should be sent to the display / / The current status of the CD line is available / / in bit 0 of u8g->com_status / spi_write_blocking(SPI_PORT, (uint8_t *)&arg, 1 ); break;
} return 1; }
spi_pins.h
/**ifndef SPI_PINS_H
define SPI_PINS_H
define SPI_PORT spi0 // we use SPI port 0
define TFT_CS 17 // chip select
define TFT_SCK 18 // Serial Clock
define TFT_MOSI 19 // Master out Slave in
define TFT_RST 21 // reset
define TFT_DC 20 // data / command
endif // SPI_PINS_H
main.c
/**// includes
include
include "pico/stdlib.h"
include "ucglib_pico.h" // interface between PICO and ucglib
/**
@return 0 */ int main() {
// creer een ucg object ucg_t ucg; // dit is hetgane die praat met het TFT scherm
// creer een functie pointer naar de callback ucg_com_fnptr ucg_pico_func = &ucg_com_pico_cb;
// initialiseer de UCG ucg_Init(&ucg, ucg_dev_st7735_18x128x160, ucg_ext_st7735_18, ucg_pico_func);
// en laat eens wat zien ucg_SetFontMode(&ucg, UCG_FONT_MODE_TRANSPARENT); ucg_ClearScreen(&ucg); ucg_SetFont(&ucg, ucg_font_8x13_mr); ucg_SetColor(&ucg, 0, 255, 255, 0); ucg_wh_t dimensions; dimensions.w = ucg_GetWidth(&ucg); dimensions.h = ucg_GetHeight(&ucg); while(1) {
ucg_ClearScreen(&ucg); ucg_SetColor(&ucg, 0, 255, 255, 0); ucg_DrawDisc (&ucg, dimensions.w/2, dimensions.h / 2, dimensions.w/2, UCG_DRAW_ALL);
} return 0; } `
CmakeLists.txt for the program `add_executable(ucg_1 main.c ../ucglib/csrc/ucglib_pico.h spi_pins.h)
eventueel zoeken in ucglib
include_directories(../ucglib/csrc)
pull in common dependencies and additional spi hardware support
target_link_libraries(ucg_1 pico_stdlib hardware_spi hardware_gpio ucglib)
create map/bin/hex file etc.
pico_add_extra_outputs(ucg_1)
add url via pico_set_program_url
example_auto_set_url(ucg_1) `
CMakeLists.txt for the library `# We gaan hier de library maken voor ucglib add_library(ucglib csrc/ucg_bitmap.c csrc/ucg_box.c csrc/ucg_ccs.c csrc/ucg_circle.c csrc/ucg_clip.c csrc/ucg_com_msg_api.c csrc/ucg_dev_default_cb.c csrc/ucg_dev_ic_hx8352c.c csrc/ucg_dev_ic_ili9163.c csrc/ucg_dev_ic_ili9325.c csrc/ucg_dev_ic_ili9325_spi.c csrc/ucg_dev_ic_ili9341.c csrc/ucg_dev_ic_ili9486.c csrc/ucg_dev_ic_ld50t6160.c csrc/ucg_dev_ic_pcf8833.c csrc/ucg_dev_ic_seps225.c csrc/ucg_dev_ic_ssd1289.c csrc/ucg_dev_ic_ssd1331.c csrc/ucg_dev_ic_ssd1351.c csrc/ucg_dev_ic_st7735.c csrc/ucg_dev_msg_api.c csrc/ucg_dev_oled_128x128_ft.c csrc/ucg_dev_oled_128x128_ilsoft.c csrc/ucg_dev_oled_128x128_univision.c csrc/ucg_dev_oled_160x128_samsung.c csrc/ucg_dev_oled_96x64_univision.c csrc/ucg_dev_tft_128x128_ili9163.c csrc/ucg_dev_tft_128x160_st7735.c csrc/ucg_dev_tft_132x132_pcf8833.c csrc/ucg_dev_tft_240x320_ili9325_spi.c csrc/ucg_dev_tft_240x320_ili9341.c csrc/ucg_dev_tft_240x320_itdb02.c csrc/ucg_dev_tft_240x320_ssd1289.c csrc/ucg_dev_tft_240x400_hx8352c.c csrc/ucg_dev_tft_320x480_ili9486.c csrc/ucg_font.c csrc/ucg_init.c csrc/ucg_line.c csrc/ucg_pixel.c csrc/ucg_pixel_font_data.c csrc/ucg_polygon.c csrc/ucg_rotate.c csrc/ucg_scale.c csrc/ucg_vector_font_data.c )
`