Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SmartSwitch.c
00001 #include "System.h" 00002 00003 DigitalOut EnableSmartSwitchPower(p27); 00004 DigitalOut SmartSwitch_SS(p24); 00005 DigitalOut SmartSwitch_SCK(p25); 00006 DigitalOut SmartSwitch_SDI(p26); 00007 00008 void SmartSwitch_ImageDump(BYTE *Img) 00009 { 00010 int i; 00011 00012 SmartSwitch_SS = 0; 00013 SmartSwitchWriteByte(SMART_SWITCH_CMD_DISPLAY_DATA); 00014 00015 for(i=0;i<256;i++) 00016 { 00017 SmartSwitchWriteByte(Img[i]); 00018 } 00019 00020 SmartSwitch_SS = 1; 00021 } 00022 00023 void SmartSwitchClear() 00024 { 00025 int i; 00026 00027 SmartSwitch_SS = 0; 00028 SmartSwitchWriteByte(SMART_SWITCH_CMD_DISPLAY_DATA); 00029 00030 for(i=0;i<256;i++) 00031 { 00032 SmartSwitchWriteByte(0x00); 00033 } 00034 00035 SmartSwitch_SS = 1; 00036 } 00037 00038 void SmartSwitch_Reset() 00039 { 00040 SmartSwitch_SS = 0; 00041 SmartSwitchWriteByte(SMART_SWITCH_CMD_RESET); 00042 SmartSwitchWriteByte(SMART_SWITCH_CMD_RESET_PARAMETER); 00043 SmartSwitch_SS = 1; 00044 } 00045 00046 void SmartSwitch_SetBackLightColor(BYTE Red,BYTE Green,BYTE Blue) 00047 { 00048 SmartSwitch_SS = 0; 00049 SmartSwitchWriteByte(SMART_SWITCH_CMD_SET_BACKLIGHT_COLOR); 00050 SmartSwitchWriteByte(Red<<6 | Green<<4 | Blue <<2 | 0x3); 00051 SmartSwitch_SS = 1; 00052 } 00053 00054 void SmartSwitch_SetBackLightColor2(BYTE RGB) 00055 { 00056 SmartSwitch_SS = 0; 00057 SmartSwitchWriteByte(SMART_SWITCH_CMD_SET_BACKLIGHT_COLOR); 00058 SmartSwitchWriteByte(RGB<<2 | 0x3); 00059 SmartSwitch_SS = 1; 00060 } 00061 00062 void SmartSwitch_SetBrightnss(BYTE Brightness) 00063 { 00064 SmartSwitch_SS = 0; 00065 SmartSwitchWriteByte(SMART_SWITCH_CMD_SET_BRIGHTNESS); 00066 SmartSwitchWriteByte(Brightness<<5 | 0x1F); 00067 SmartSwitch_SS = 1; 00068 } 00069 00070 00071 00072 void InitSmartSwitch() 00073 { 00074 SmartSwitch_SS = 1; 00075 SmartSwitch_SCK = 1; 00076 SmartSwitch_SDI = 1; 00077 PowerUpSmartSwitch(); 00078 SmartSwitch_Reset(); 00079 00080 } 00081 00082 void PowerUpSmartSwitch() 00083 { 00084 EnableSmartSwitchPower = 1; 00085 } 00086 00087 void PowerDownSmartSwitch() 00088 { 00089 EnableSmartSwitchPower = 0; 00090 } 00091 00092 void SmartSwitchWriteByte(BYTE DataOut) 00093 { 00094 BYTE i; 00095 00096 SmartSwitch_SCK = 1; 00097 00098 for(i=0;i<8;i++) 00099 { 00100 if(DataOut & (0x01<<(7-i))) 00101 { 00102 SmartSwitch_SDI = 1; 00103 } 00104 else 00105 { 00106 SmartSwitch_SDI = 0; 00107 } 00108 00109 SmartSwitch_SCK = 0; 00110 SmartSwitch_SCK = 1; 00111 } 00112 } 00113 00114
Generated on Thu Jul 14 2022 09:05:34 by
1.7.2