This is an digital video camera program using NKK\'s oLED swtich and 4D Systems\' uCam serial camera. It takes image from the uCam and displays on the IS-C15 switch. Some image processing demos are included. This program uses FatFileSytem, SDFileSystem, and TextLCD library. See http://www.youtube.com/watch?v=fqHTaCRHyQs for how it works. CQ出版社の「mbed/ARM活用事例」第10章シリアル接続カメラと有機ELディスプレイ内蔵スイッチで作るmbedディジタル・カメラの作例です。動作の様子は http://www.youtube.com/watch?v=fqHTaCRHyQs で見れます。
Dependencies: TextLCD mbed SDFileSystem
isc15.cpp
00001 /* mbed NKK IS-C15/C01 oLED switch library 00002 * Copyright (c) 2011, Noriaki Mitsunaga 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy 00005 * of this software and associated documentation files (the "Software"), to deal 00006 * in the Software without restriction, including without limitation the rights 00007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 * copies of the Software, and to permit persons to whom the Software is 00009 * furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included in 00012 * all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00020 * THE SOFTWARE. 00021 */ 00022 #include "isc15.h" 00023 00024 //////////////////////////////////////////////////////////////////////////////////////// 00025 // Some constants 00026 //////////////////////////////////////////////////////////////////////////////////////// 00027 const int DAT = 1; 00028 const int CMD = 0; 00029 00030 //////////////////////////////////////////////////////////////////////////////////////// 00031 // OLED's initial setup commands (IS15) 00032 //////////////////////////////////////////////////////////////////////////////////////// 00033 const unsigned char SetupColumnAddress[] = { 0x03, 0x15, 0x10, 0x4f }; 00034 const unsigned char SetupRowaddress[] = { 0x03, 0x75, 0x00, 0x2f }; 00035 const unsigned char SetContrastColorA[] = { 0x02, 0x81, 0x19 }; 00036 const unsigned char SetContrastColorB[] = { 0x02, 0x82, 0x14 }; 00037 const unsigned char SetContrastColorC[] = { 0x02, 0x83, 0x24 }; 00038 const unsigned char MasterCurrentControl[] = { 0x02, 0x87, 0x0f }; 00039 const unsigned char RemapColorDepth[] = { 0x02, 0xa0, 0x70 }; 00040 const unsigned char SetDisplayStartLine[] = { 0x02, 0xa1, 0x00 }; 00041 const unsigned char SetDisplayOffset[] = { 0x02, 0xa2, 0x10 }; 00042 const unsigned char SetDisplayMode[] = { 0x01, 0xa4 }; 00043 const unsigned char SetMultiplexRatio[] = { 0x02, 0xa8, 0x2f }; 00044 const unsigned char DimModeSetting[] = { 0x05, 0xab, 0x12, 0x0c, 0x14, 0x12 }; 00045 const unsigned char SetDisplayDim[] = { 0x01, 0xac }; 00046 const unsigned char SetDisplayOff[] = { 0x01, 0xae }; 00047 const unsigned char SetDisplayNormal[] = { 0x01, 0xaf }; 00048 const unsigned char SetMasterConfiguration[] = { 0x02, 0xad, 0x8e }; 00049 const unsigned char PhasePeriodAdjustment[] = { 0x02, 0xb1, 0x44 }; 00050 const unsigned char DisplayClockDivider[] = { 0x02, 0xb3, 0xa0 }; 00051 const unsigned char EnableLinearGrayScale[] = { 0x01, 0xb9 }; 00052 const unsigned char SetPrechargeLevel[] = { 0x02, 0xbb, 0x12 }; 00053 const unsigned char SetVcomh[] = { 0x03, 0xbe, 0x28 }; 00054 00055 const unsigned char ColorDepth64k[] = { 0x02, 0xa0, 0x70 }; 00056 const unsigned char ColorDepth256[] = { 0x02, 0xa0, 0x30 }; 00057 00058 // OLED's initial setup commands (for display only type (IS01) ) 00059 const unsigned char SetupColumnAddress_d[] = { 0x03, 0x15, 0x16, 0x49 }; //display 00060 const unsigned char SetupRowaddress_d[] = { 0x03, 0x75, 0x00, 0x23 }; //display 00061 const unsigned char SetContrastColorA_d[] = { 0x02, 0x81, 0x0f }; //display 00062 const unsigned char SetContrastColorB_d[] = { 0x02, 0x82, 0x0e }; //display 00063 const unsigned char SetContrastColorC_d[] = { 0x02, 0x83, 0x1b }; //display 00064 const unsigned char SetDisplayOffset_d[] = { 0x02, 0xa2, 0x1c }; //display 00065 const unsigned char SetMultiplexRatio_d[] = { 0x02, 0xa8, 0x23 }; //display 00066 const unsigned char DimModeSetting_d[] = { 0x05, 0xab, 0x0b, 0x08, 0x0f, 0x12 }; //display 00067 const unsigned char DisplayClockDivider_d[] = { 0x02, 0xb3, 0x30 }; //display 00068 const unsigned char SetVcomh_d[] = { 0x03, 0xbe, 0x21 }; //display 00069 00070 // 00071 // Change OLED's address setting 00072 // 00073 void ISC15::AdrInit( int DevType ) { 00074 if (spi == NULL) 00075 return; 00076 00077 if (DevType == ISC15_DEVICE_ISC15) { 00078 SendCommand( SetupColumnAddress ); 00079 SendCommand( SetupRowaddress ); 00080 } else { 00081 SendCommand( SetupColumnAddress_d ); 00082 SendCommand( SetupRowaddress_d ); 00083 } 00084 } 00085 00086 00087 // 00088 // Display data on OLED 00089 // 00090 void ISC15::Disp( int Mode, const unsigned char *dat ) { 00091 if (spi == NULL) 00092 return; 00093 00094 AdrInit(DevType); 00095 DspMode(Mode); 00096 if (Mode == ISC15_DSPMODE_64K) 00097 SendData(dat, ISC15_WIDTH*ISC15_HEIGHT*2); 00098 else 00099 SendData(dat, ISC15_WIDTH*ISC15_HEIGHT); 00100 } 00101 00102 // 00103 // Change OLED's color depth setting (64K or 256 colors) 00104 // 00105 void ISC15::DspMode( int DspMode ) { 00106 if (spi == NULL) 00107 return; 00108 00109 if ( DspMode == ISC15_DSPMODE_64K ) { 00110 SendCommand( ColorDepth64k ); 00111 } else { 00112 SendCommand( ColorDepth256 ); 00113 } 00114 } 00115 00116 // 00117 // Fill out display 00118 // 00119 void ISC15::Fill(unsigned char c) { 00120 if (spi == NULL) 00121 return; 00122 00123 AdrInit(DevType); 00124 DspMode(0); 00125 00126 is_dc = DAT; 00127 for (int i = ISC15_WIDTH*ISC15_HEIGHT; i>0; i --) { 00128 is_cs = 0; 00129 spi->write(c); 00130 is_cs = 1; 00131 } 00132 } 00133 00134 // 00135 // initial settings of OLED 00136 // 00137 void ISC15::Init( int DeviceType, SPI *s ) { 00138 volatile unsigned char delay = 0x20; 00139 00140 DevType = DeviceType; 00141 spi = s; 00142 00143 // reset OLED 00144 is_vcc = 0; 00145 is_reset = 0; 00146 wait_us(3); 00147 is_reset = 1; 00148 is_vcc = 1; 00149 00150 // initial settings 00151 AdrInit(DevType); 00152 00153 if (DevType == ISC15_DEVICE_ISC15) { 00154 SendCommand( SetContrastColorA ); 00155 SendCommand( SetContrastColorB ); 00156 SendCommand( SetContrastColorC ); 00157 SendCommand( MasterCurrentControl ); 00158 SendCommand( SetDisplayStartLine ); 00159 SendCommand( SetDisplayOffset ); 00160 SendCommand( SetDisplayMode ); 00161 SendCommand( SetMultiplexRatio ); 00162 SendCommand( DimModeSetting ); 00163 SendCommand( SetMasterConfiguration ); 00164 SendCommand( PhasePeriodAdjustment ); 00165 SendCommand( DisplayClockDivider ); 00166 SendCommand( EnableLinearGrayScale ); 00167 SendCommand( SetPrechargeLevel ); 00168 SendCommand( SetVcomh ); 00169 } else { 00170 SendCommand( SetContrastColorA_d ); 00171 SendCommand( SetContrastColorB_d ); 00172 SendCommand( SetContrastColorC_d ); 00173 SendCommand( MasterCurrentControl ); 00174 SendCommand( SetDisplayStartLine ); 00175 SendCommand( SetDisplayOffset_d ); 00176 SendCommand( SetDisplayMode ); 00177 SendCommand( SetMultiplexRatio_d ); 00178 SendCommand( DimModeSetting_d ); 00179 SendCommand( SetMasterConfiguration ); 00180 SendCommand( PhasePeriodAdjustment ); 00181 SendCommand( DisplayClockDivider_d ); 00182 SendCommand( EnableLinearGrayScale ); 00183 SendCommand( SetPrechargeLevel ); 00184 SendCommand( SetVcomh_d ); 00185 } 00186 00187 // display mode settings 00188 DspMode( ISC15_DSPMODE_64K); 00189 00190 SendCommand( SetDisplayNormal ); 00191 } 00192 00193 // 00194 // Send a command / data to OLED via SPI 00195 // 00196 void ISC15::Send( const unsigned char *p, int len ) { 00197 if (spi == NULL) 00198 return; 00199 00200 for (; len>0; len --, p ++) { 00201 is_cs = 0; 00202 spi->write(*p); 00203 is_cs = 1; 00204 } 00205 } 00206 00207 // 00208 // Send a command to OLED 00209 // 00210 void ISC15::SendCommand( const unsigned char *com ) { 00211 if (spi == NULL) 00212 return; 00213 00214 is_dc = CMD; 00215 Send(com+1, *com); 00216 } 00217 00218 // 00219 // Send data to OLED 00220 // 00221 void ISC15::SendData( const unsigned char *dat, int len ) { 00222 if (spi == NULL) 00223 return; 00224 00225 is_dc = DAT; 00226 Send(dat, len); 00227 }
Generated on Wed Jul 13 2022 21:19:27 by 1.7.2