Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major Update #16

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions C/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
Target = display
CXX = gcc
ODIR = obj
SRC =$(wildcard *.c)
DIR =$(notdir $(SRC))
OBJ = $(patsubst %.c, %.o, $(DIR))
Target = display
CFLAGS = -Wall
CXX = gcc
LIBS =
ODIR = obj
SRC = $(wildcard *.c)
DIR = $(notdir $(SRC))
OBJ = $(patsubst %.c, %.o, $(DIR))
$(Target): $(OBJ)
$(CXX) $^ -o $@ -g -rdynamic
.PHONY:clean
$(CXX) $^ -o $@ $(LIBS)
.PHONY: clean
clean:
rm -rf *.o
rm -rf $(Target)
32 changes: 0 additions & 32 deletions C/README.md

This file was deleted.

166 changes: 100 additions & 66 deletions C/bmp.h

Large diffs are not rendered by default.

71 changes: 43 additions & 28 deletions C/display.c
Original file line number Diff line number Diff line change
@@ -1,35 +1,50 @@
/******
Demo for ssd1306 i2c driver for Raspberry Pi
******/
#include <stdio.h>
#include "ssd1306_i2c.h"
#include "time.h"
#include <unistd.h>
/*********************************************************************
* Demo for SSD1306 I2C driver for Raspberry Pi
*********************************************************************/

#include <signal.h>
#include <stdlib.h> // exit
#include <unistd.h> // sleep, usleep
#include "ssd1306_i2c.h" // LCD_Display, ssd1306_begin

void sig_handler(int signum) // Return type of the handler function should be void
{
switch (signum)
{
case SIGHUP:
OLED_Clear();
exit(0);
case SIGINT:
OLED_Clear();
exit(0);
case SIGTERM:
OLED_Clear();
exit(0);
default:
break;
}
}

int main(void)
int main(void)
{
unsigned char symbol=0;
ssd1306_begin(SSD1306_SWITCHCAPVCC, SSD1306_I2C_ADDRESS); //LCD Screen initialization
if(i2cd<0)
{
printf("I2C device failed to open\r\n");
return 0;
}
usleep(150*1000); //Short delay Ensure the normal response of the lower function
FirstGetIpAddress(); //Get IP address
while(1)
unsigned short int count = 0;

signal(SIGHUP, sig_handler); // Register signal handler (can't catch SIGKILL or SIGSTOP)
signal(SIGINT, sig_handler); // Register signal handler (can't catch SIGKILL or SIGSTOP)
signal(SIGTERM, sig_handler); // Register signal handler (can't catch SIGKILL or SIGSTOP)

ssd1306_begin(SSD1306_SWITCHCAPVCC, SSD1306_I2C_ADDRESS); // LCD Screen initialization
usleep(150000); // Short delay to ensure the normal response of the lower functions

// Loop forever
for (;;)
{
LCD_Display(count);
sleep(1);
count++;
if (count > 2)
{
LCD_Display(symbol);
sleep(1);
sleep(1);
sleep(1);
symbol++;
if(symbol==3)
{
symbol=0;
}
count = 0;
}
return 0;
}
}
Loading