Merge pull request #2 from gsmecher/tidy
Code clean-ups: squash warnings; Makefile dependencies
This commit is contained in:
commit
7375f10887
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
*.o
|
*.o
|
||||||
|
*.d
|
||||||
ssd1306_bin
|
ssd1306_bin
|
||||||
|
16
Makefile
16
Makefile
@ -1,15 +1,25 @@
|
|||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-I ./
|
CFLAGS=-I ./ -Wall -Werror
|
||||||
LDFLAGS=-static
|
LDFLAGS=-static
|
||||||
OBJS=main.o ssd1306.o linux_i2c.o
|
OBJS=main.o ssd1306.o linux_i2c.o
|
||||||
BIN=ssd1306_bin
|
BIN=ssd1306_bin
|
||||||
|
|
||||||
|
default: $(BIN)
|
||||||
|
.PHONY: default clean
|
||||||
|
|
||||||
|
# Adapted from scottmcpeak.com/autodepend/autodepend.html
|
||||||
|
-include $(OBJS:.o=.d)
|
||||||
%.o: %.c
|
%.o: %.c
|
||||||
$(CC) -c -o $@ $< $(CFLAGS)
|
$(CC) -c $(CFLAGS) $< -o $*.o
|
||||||
|
$(CC) -MM $(CFLAGS) $< > $*.d
|
||||||
|
@cp -f $*.d $*.d.tmp
|
||||||
|
@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
|
||||||
|
sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
|
||||||
|
@rm -f $*.d.tmp
|
||||||
|
|
||||||
$(BIN):$(OBJS)
|
$(BIN):$(OBJS)
|
||||||
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)
|
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f ./*.o $(BIN)
|
rm -f *.o *.d $(BIN)
|
||||||
|
|
||||||
|
@ -52,8 +52,7 @@ uint8_t _i2c_write(uint8_t* ptr, int16_t len)
|
|||||||
if (file_i2c == 0 || ptr == 0 || len <= 0)
|
if (file_i2c == 0 || ptr == 0 || len <= 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
int32_t rc;
|
write(file_i2c, ptr, len);
|
||||||
rc = write(file_i2c, ptr, len);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -63,8 +62,7 @@ uint8_t _i2c_read(uint8_t *ptr, int16_t len)
|
|||||||
if (file_i2c == 0 || ptr == 0 || len <= 0)
|
if (file_i2c == 0 || ptr == 0 || len <= 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
int32_t rc;
|
read(file_i2c, ptr, len);
|
||||||
rc = read(file_i2c, ptr, len);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
6
main.c
6
main.c
@ -30,9 +30,9 @@ int main(int argc, char **argv)
|
|||||||
uint8_t i2c_node_address = 0;
|
uint8_t i2c_node_address = 0;
|
||||||
int x = -1;
|
int x = -1;
|
||||||
int y = -1;
|
int y = -1;
|
||||||
uint8_t line[25] = {0};
|
char line[25] = {0};
|
||||||
uint8_t msg[200] = {0};
|
char msg[200] = {0};
|
||||||
uint8_t oled_type[10] = {0};
|
char oled_type[10] = {0};
|
||||||
int clear_line = -1;
|
int clear_line = -1;
|
||||||
int clear_all = -1;
|
int clear_all = -1;
|
||||||
int orientation = -1;
|
int orientation = -1;
|
||||||
|
13
ssd1306.c
13
ssd1306.c
@ -12,10 +12,9 @@
|
|||||||
#include <ssd1306.h>
|
#include <ssd1306.h>
|
||||||
#include <font.h>
|
#include <font.h>
|
||||||
|
|
||||||
const uint8_t init_oled_type_file[] = "/tmp/.ssd1306_oled_type";
|
const char init_oled_type_file[] = "/tmp/.ssd1306_oled_type";
|
||||||
|
|
||||||
static uint8_t data_buf[1024];
|
static uint8_t data_buf[1024];
|
||||||
static int16_t data_len = 0;
|
|
||||||
static uint8_t max_lines = 0;
|
static uint8_t max_lines = 0;
|
||||||
static uint8_t max_columns = 0;
|
static uint8_t max_columns = 0;
|
||||||
static uint8_t global_x = 0;
|
static uint8_t global_x = 0;
|
||||||
@ -309,7 +308,7 @@ uint8_t ssd1306_oled_default_config(uint8_t oled_lines, uint8_t oled_columns)
|
|||||||
return _i2c_write(data_buf, i);
|
return _i2c_write(data_buf, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ssd1306_oled_write_line(uint8_t size, uint8_t* ptr)
|
uint8_t ssd1306_oled_write_line(uint8_t size, char* ptr)
|
||||||
{
|
{
|
||||||
uint16_t i = 0;
|
uint16_t i = 0;
|
||||||
uint16_t index = 0;
|
uint16_t index = 0;
|
||||||
@ -357,16 +356,16 @@ uint8_t ssd1306_oled_write_line(uint8_t size, uint8_t* ptr)
|
|||||||
return _i2c_write(data_buf, i);
|
return _i2c_write(data_buf, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ssd1306_oled_write_string(uint8_t size, uint8_t* ptr)
|
uint8_t ssd1306_oled_write_string(uint8_t size, char* ptr)
|
||||||
{
|
{
|
||||||
uint8_t rc = 0;
|
uint8_t rc = 0;
|
||||||
|
|
||||||
if (ptr == 0)
|
if (ptr == 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
uint8_t* line = 0;
|
char* line = 0;
|
||||||
uint8_t* cr = 0;
|
char* cr = 0;
|
||||||
uint8_t buf[20];
|
char buf[20];
|
||||||
|
|
||||||
line = ptr;
|
line = ptr;
|
||||||
do {
|
do {
|
||||||
|
@ -75,8 +75,8 @@ uint8_t ssd1306_oled_set_Y(uint8_t y);
|
|||||||
uint8_t ssd1306_oled_set_XY(uint8_t x, uint8_t y);
|
uint8_t ssd1306_oled_set_XY(uint8_t x, uint8_t y);
|
||||||
uint8_t ssd1306_oled_set_rotate(uint8_t degree);
|
uint8_t ssd1306_oled_set_rotate(uint8_t degree);
|
||||||
uint8_t ssd1306_oled_default_config(uint8_t oled_lines, uint8_t oled_columns);
|
uint8_t ssd1306_oled_default_config(uint8_t oled_lines, uint8_t oled_columns);
|
||||||
uint8_t ssd1306_oled_write_line(uint8_t size, uint8_t* ptr);
|
uint8_t ssd1306_oled_write_line(uint8_t size, char* ptr);
|
||||||
uint8_t ssd1306_oled_write_string(uint8_t size, uint8_t* ptr);
|
uint8_t ssd1306_oled_write_string(uint8_t size, char* ptr);
|
||||||
uint8_t ssd1306_oled_clear_line(uint8_t row);
|
uint8_t ssd1306_oled_clear_line(uint8_t row);
|
||||||
uint8_t ssd1306_oled_clear_screen();
|
uint8_t ssd1306_oled_clear_screen();
|
||||||
uint8_t ssd1306_oled_save_resolution(uint8_t column, uint8_t row);
|
uint8_t ssd1306_oled_save_resolution(uint8_t column, uint8_t row);
|
||||||
|
Loading…
Reference in New Issue
Block a user