Skip to content

NCKU_electronic_bookcases_PR #20

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

Open
wants to merge 2 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
141 changes: 141 additions & 0 deletions arc_design_contest/2018/NCKU_electronic_bookcases/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
arc-2018-Team4 electronic bookcases
==================

* [Introduction](#overview)
* [Video](#video)
* [Configuration](#struct)
* [Hardware](#hardware)
* [Software](#software)
* [Makefile](#Makefile)
* [source code](#code)

<h2 id="overview">Introduction</h2>

The project name is “electronic bookcases”, which is designed to digitize the information inside the library.

With the server that stores the data, administrators can easily manage and directly grasp the first-hand information at any time.

As for clients, procedures such as borrowing or returning books will be facilitated. Clients will be able to handle several formalities by interacting with such system instead of librarian. The system will then collect related data so that administrators can do their work with comfort.

Moreover, we hope to promote the system for in-depth analysis. Throughout further operation which provides convenient capability of management, administrators can be aware of popularity of certain books or have other thorough information in hand.


<h2 id="video">Video</h2>
https://v.youku.com/v_show/id_XMzY3OTI0MDg3Ng==.html?spm=a2h3j.8428770.3416059.1

<h2 id="struct">Configuration</h2>
<h3 id="hardware">Hardware</h3>

* **DesignWare ARC EM Starter Kit(EMSK)**

* **Linkit 7688 DUO**

* **LCD**

* **Keyboard**
* **A lot of LEDS (depend on how big your shelf is)**

The version of EM Starter Kit is currently EMSK22 em7d.

Linkit 7688 DUO is meant to build internet connection between client and server side.

#### Hardware Connection
1. The linkit 7688 DUO is connected with ARC EMSK via uart on **J1**
2. Lcd is connected with ARC EMSK via I2C on **J4**
3. Keyboard is connected with ARC EMSK via gpio on **J3**
4. LEDS are connected with ARC EMSK via gpio on **J5 and J6**
5. Configure your EMSKs with proper core configuration.

<h3 id="software">Software</h3>

* **Metaware or ARC GNU Toolset**
* **Arduino IDE (for linkit 7688 DUO mcu)**
* **Filezilla or other ftp software**
* **Serial port terminal, such as putty, tera-term or minicom (for linkit 7688 DUO mpu)**

In this project, we use **embarc osp 2017.12** and **arc gnu tool chain 2017.09**

#### Run This Application

Modify the settings for connecting to the App, as shown below:

Here take **EMSK2.2 - ARC EM7D** with GNU Toolset and **Linkit 7688 DUO** with Arduino IDE and filezilla for example to show how to run this application.

1. We need to use embARC GNU Toolset to load application for EMSK and run.

2. Set linkit to client mode and connect to wifi router.

3. Open Arduino IDE to load application for linkit 7688 DUO MCU and run.

4. Open putty and start a ssh connect with linkit MPU.

5. Open Filezilla to upload application for linkit 7688 DUO MPU and use putty to run.
-Before running application on linkit 7688 DUO MPU , modify following code first:

url="http://192.168.1.103//ARC2DB.php"

**URL depends on where your mySQL server is.**

<h5 id="Makefile">Get ipaddress</h5>

- Take Windows as example:

command line: ipconfig

<h3 id="Makefile">Makefile</h3>

- Target options about EMSK and toolchain:

BOARD ?= emsk
BD_VER ?= 22
CUR_CORE ?= arcem7d
TOOLCHAIN ?= gnu

- The relative series of the root directory, depends on your structure.

#
# root dir of embARC
#
EMBARC_ROOT = ../..

<h2 id="code">source code</h2>

* **src**

| folder/file | Function |
| ------------------------ | -----------------------------------|
| src/arc | source code for EMBARC |
| src/linkit7688 | source code for linkit7688DUO |
| src/database | source code for database (mySQL) |

* **src/arc/**

| folder/file | Function |
| ------------------------ | -----------------------------------|
| team4/ | project's source code folder |
| team4/main.h & main.c | project's main function |
| team4/LCD.h & LCD.c | LCD drivers |
| team4/makefile | project's configuration |

* **src/linkit7688**

| folder/file | Function |
| -------------------------- | ----------------------------------------------------- |
| linkit-mpu/ | linkit 7688 DUO mpu source code folder |
| linkit-mpu/arc2018.py | deal with network in this project |
| linkit_mcu/ | linkit 7688 DUO arduino-compatible mcu source code folder|
| linkit_mcu/linkit_mcu.ino | bridge between **arc emsk** and **linkit MPU** |

* **src/database/Library**

| folder/file | Function |
| -------------------------------- | -------------------------------------------|
| ARC2DB.php | project source code for database operation |
| ARC-Hive Library Information.php| display all information |
| Book.php | display books' status |
| connect database.php | project source code for database connection|
| Location.php | display available location |
| ReservationRecoed.php | display reservation history of each books |
| WaitingQueue.php | display current reservation status |


Binary file not shown.
122 changes: 122 additions & 0 deletions arc_design_contest/2018/NCKU_electronic_bookcases/src/arc/team4/LCD.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#include "LCD.h"

static DEV_IIC *LCD;
/*****************************************************************************
Lcd_Init - setup spi port for LCD driver
*****************************************************************************/
void Lcd_Init(DEV_IIC *LCD_obj) {
LCD = LCD_obj;
}

/*****************************************************************************
Lcd_ClearScreen - CLear screen
*****************************************************************************/
void Lcd_ClearScreen(void) {
uint8_t iic_cmd[4] = { 0x1B, '[', '0', 'j' };
LCD->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_RESTART));
LCD->iic_write(iic_cmd, 4);
//LCD->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_STOP));
}

/*****************************************************************************
Lcd_Home - set cursor at home position
*****************************************************************************/
void Lcd_Home(void) {
uint8_t iic_cmd[6] = { 0x1B, '[', '0', ';', '0', 'H' };
LCD->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_RESTART));
LCD->iic_write(iic_cmd, 6);
//LCD->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_STOP));
}

/*****************************************************************************
Lcd_Cursor - set cursor at postion row:col
*****************************************************************************/
void Lcd_Cursor(uint8_t row, uint8_t col) {
unsigned char col_first_digit = col / 10 + '0';
unsigned char col_second_digit = col % 10 + '0';
uint8_t iic_cmd[MAX_LCD_COL + 7] = { 0x1B, '[', row + '0', ';',
col_first_digit, col_second_digit, 'H' };

LCD->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_RESTART));
LCD->iic_write(iic_cmd, 7);
//LCD->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_STOP));
}

/*****************************************************************************
Lcd_CursorOff - swtch cursor off
*****************************************************************************/
void Lcd_CursorOff(void) {
uint8_t iic_cmd[4] = { 0x1B, '[', '0', 'c' };
LCD->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_RESTART));
LCD->iic_write(iic_cmd, 4);
//LCD->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_STOP));
}
/*****************************************************************************
Lcd_ClearRow - clear selected row
*****************************************************************************/
void Lcd_ClearRow(uint8_t row) {
// set cursor to start position of the line
Lcd_Cursor(row, 0);
//erase from current pos to end of line
uint8_t iic_cmd[4] = { 0x1B, '[', '0', 'K' };
LCD->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_RESTART));
LCD->iic_write(iic_cmd, 4);
//LCD->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_STOP));
}

/*****************************************************************************
Lcd_DisplayMode - Set 16-byte of 40 bytes stings length
*****************************************************************************/
void Lcd_DisplayMode(int onoff) {
uint8_t iic_cmd[4] = { 0x1B, '[', '0', 'h' };

if (onoff == 1) {
iic_cmd[2] = '0'; //wrap @ 16 chars
} else {
iic_cmd[2] = '1'; //wrap @ 40 chars
}
LCD->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_RESTART));
LCD->iic_write(iic_cmd, 4);
//LCD->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_STOP));
}

/*****************************************************************************
Lcd_DisplayOnOff - On/Off display
*****************************************************************************/
void Lcd_DisplayOnOff(int onoff) {
uint8_t iic_cmd[4] = { 0x1B, '[', '3', 'e' };

if (onoff == 1) {
iic_cmd[2] = '1'; //on
} else {
iic_cmd[2] = '0'; //off
}
LCD->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_RESTART));
LCD->iic_write(iic_cmd, 4);
//LCD->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_STOP));
}
void Lcd_DisplayString(uint8_t row, uint8_t col, char *strng) {
unsigned int length = 0;
unsigned char byte;
unsigned int i;
uint8_t *bufptr;
uint8_t iic_cmd[MAX_LCD_COL];

Lcd_ClearRow(row);
Lcd_Cursor(row, col);

bufptr = iic_cmd;
for (i = length = 0; i < MAX_LCD_COL; i++) {
byte = *strng++;
if (byte) {
if (byte != '\r' && byte != '\n') {
*bufptr++ = byte;
length++;
}
} else
break;
}
LCD->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_RESTART));
LCD->iic_write(iic_cmd, length);
//LCD->iic_control(IIC_CMD_MST_SET_NEXT_COND, CONV2VOID(IIC_MODE_STOP));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "embARC.h"
#include "embARC_debug.h"
/***************************FOR PMOD CLS LCD*************************************/
#define MAX_LCD_COL 16
/***************************Fun Declaration******************************/
void Lcd_Init (DEV_IIC *LCD_obj);
void Lcd_ClearScreen (void);
void Lcd_Home (void);
void Lcd_Cursor (uint8_t row, uint8_t col);
void Lcd_CursorOff (void);
void Lcd_ClearRow (uint8_t row);
void Lcd_DisplayMode (int onoff);
void Lcd_DisplayOnOff (int onoff);
void Lcd_DisplayString(uint8_t row, uint8_t col, char *strng);
Loading