📄 display_driver.txt
字号:
1194. u16SourceWinStop_high=(uint16_t)(((u32XDst + *pu32Width - 1)&0x0000FF00)>>8);
1195. u16SourceWinStop_low=(uint16_t)((u32XDst + *pu32Width - 1)&0x000000FF);
1196.
1197. u16GateWinStart_high=(uint16_t)(((u32YDst)&0x0000FF00)>>8);
1198. u16GateWinStart_low=(uint16_t)((u32YDst)&0x000000FF);
1199. u16GateWinStop_high=(uint16_t)(((u32YDst + *pu32Height - 1)&0x0000FF00)>>8);
1200. u16GateWinStop_low=(uint16_t)((u32YDst + *pu32Height - 1)&0x000000FF);
1201. break;
1202. }
1203. WriteDirect(CMD_MODE,0x02);
1204. WriteDirect(DATA_MODE,u16SourceWinStart_high);
1205.
1206. WriteDirect(CMD_MODE,0x03);
1207. WriteDirect(DATA_MODE,u16SourceWinStart_low );
1208.
1209. WriteDirect(CMD_MODE,0x04);
1210. WriteDirect(DATA_MODE,u16SourceWinStop_high);
1211.
1212. WriteDirect(CMD_MODE,0x05);
1213. WriteDirect(DATA_MODE,u16SourceWinStop_low);
1214.
1215. WriteDirect(CMD_MODE,0x06);
1216. WriteDirect(DATA_MODE,u16GateWinStart_high);
1217.
1218. WriteDirect(CMD_MODE,0x07);
1219. WriteDirect(DATA_MODE,u16GateWinStart_low);
1220.
1221. WriteDirect(CMD_MODE,0x08);
1222. WriteDirect(DATA_MODE,u16GateWinStop_high);
1223.
1224. WriteDirect(CMD_MODE,0x09);
1225. WriteDirect(DATA_MODE,u16GateWinStop_low);
1226.
1227. WriteDirect(CMD_MODE,0x22);
1228. return ret;
1229. }
1230.
1231.
1232. ////////////////////////////////////////////////////////////////////////////////
1233. //! \fn RtStatus_t SendControllerBitmapType(gfx_BitmapTypeEnum_t eBitmapType)
1234. //!
1235. //! \brief Sets up the controller for the specified bitmap format
1236. //!
1237. //! \fntype Function
1238. //!
1239. //! \param[in] eBitmapType - The new bitmap format
1240. //!
1241. //! This function sends the appropriate commands to the display controller
1242. //! to set it up for the new bitmap type format.
1243. //!
1244. //! \retval SUCCESS No error
1245. //!
1246. //! \retval ERROR_DDI_DISPLAY_CONTROLLER_BITMAP_TYPE_UNSUPPORTED - The specified bitmap
1247. //! type is not supported by the controller
1248. //!
1249. ////////////////////////////////////////////////////////////////////////////////
1250. static RtStatus_t SendControllerBitmapType(gfx_BitmapTypeEnum_t eBitmapType)
1251. {
1252. // Only 16-bit 565 mode supported
1253. if( eBitmapType != BITMAP_TYPE_16BPP_565 )
1254. return ERROR_DDI_DISPLAY_CONTROLLER_BITMAP_TYPE_UNSUPPORTED;
1255. return SUCCESS;
1256. }
1257.
1258. ////////////////////////////////////////////////////////////////////////////////
1259. //! \fn static RtStatus_t SendControllerResolution(uint16_t u16Width, uint16_t u16Height, ddi_display_Rotation_t eRotation)
1260. //!
1261. //! \brief Sets up the controller for the specified resolution
1262. //!
1263. //! \fntype Function
1264. //!
1265. //! \param[in] u16Width - Desired width of the display
1266. //! \param[in] u16Height - Desired height of the display
1267. //! \param[in] eRotation Desired orientation of the display
1268. //!
1269. //! The display driver is built with a default width and height for each
1270. //! controller. Most controllers support displays of varying screen
1271. //! dimensions. In order to support all possible dimensions without rebuilding
1272. //! the display libraries, this function can set the dimensions of the display
1273. //! to match the actual display in use. This function only needs to be called
1274. //! once to set the dimensions for the currently set screen orientation. If the
1275. //! display is rotated after the dimensions are set, then the dimensions will
1276. //! be adjusted accordingly in the display driver. There is no need to reset
1277. //! the dimensions after rotating the display.
1278. //!
1279. //! \retval SUCCESS No error
1280. //!
1281. //! \retval ERROR_DDI_DISPLAY_CONTROLLER_RESOLUTION - The specified resolution is
1282. //! not supported by the controller
1283. //!
1284. ////////////////////////////////////////////////////////////////////////////////
1285. static RtStatus_t SendControllerResolution(uint16_t u16Width, uint16_t u16Height, ddi_display_Rotation_t eRotation)
1286. {
1287. uint16_t u16MaxWidth;
1288. uint16_t u16MaxHeight;
1289.
1290. // max dimensions are rotation specific
1291. switch(eRotation)
1292. {
1293. case DDI_DISPLAY_ROTATION_NONE:
1294. case DDI_DISPLAY_ROTATION_180:
1295. u16MaxWidth = DDI_DISPLAY_CONTROLLER_MAX_WIDTH;
1296. u16MaxHeight = DDI_DISPLAY_CONTROLLER_MAX_HEIGHT;
1297. break;
1298.
1299. case DDI_DISPLAY_ROTATION_90:
1300. case DDI_DISPLAY_ROTATION_270:
1301. u16MaxWidth = DDI_DISPLAY_CONTROLLER_MAX_HEIGHT;
1302. u16MaxHeight = DDI_DISPLAY_CONTROLLER_MAX_WIDTH;
1303. break;
1304. }
1305.
1306. // Check for out of bounds
1307. if( u16Width > u16MaxWidth || u16Height > u16MaxHeight )
1308. return ERROR_DDI_DISPLAY_CONTROLLER_RESOLUTION;
1309.
1310. return SUCCESS;
1311. }
1312.
1313. ////////////////////////////////////////////////////////////////////////////////
1314. //! \fn static RtStatus_t SendControllerRotation(ddi_display_Rotation_t eRotation)
1315. //!
1316. //! \brief Sets up the controller for the specified rotation
1317. //!
1318. //! \fntype Function
1319. //!
1320. //! \param[in] eRotation - Desired orientation of the display
1321. //!
1322. //! When the display driver is instructed to orient the screen to a new
1323. //! rotation, this function sends a command to the controller to indicate this change.
1324. //!
1325. //! \retval SUCCESS No error
1326. //!
1327. //! \retval ERROR_DDI_DISPLAY_CONTROLLER_ROTATION - The specified rotation is
1328. //! not supported by the controller
1329. //!
1330. ////////////////////////////////////////////////////////////////////////////////
1331. static RtStatus_t SendControllerRotation(ddi_display_Rotation_t eRotation)
1332. {
1333. RtStatus_t ret = SUCCESS;
1334. Hx8347aEntryMode EntryMode = {0x00A8};
1335. //EntryMode.B.Reserved= 0;
1336. //EntryMode.B.BGR=1;
1337. //EntryMode.B.ML=0;
1338. //EntryMode.B.MV=1;
1339. //EntryMode.B.MX=1;
1340. //EntryMode.B.MY=0;
1341. //EntryMode.B.Reserved1=0;
1342.
1343.
1344. // Gate/Source diagram
1345. //
1346. // 240
1347. // S719 S0
1348. // ---------------------
1349. // | | G0
1350. // | |
1351. // | |
1352. // | |
1353. // | |
1354. // | |
1355. // | | 320
1356. // | |
1357. // | |
1358. // | |
1359. // | |
1360. // | |
1361. // | | G319
1362. // ---------------------
1363. // |Ribbon cable |
1364. // ---------------
1365. //
1366. switch(eRotation)
1367. {
1368. case DDI_DISPLAY_ROTATION_NONE:
1369. EntryMode.V=0x00A8;
1370. break;
1371.
1372. case DDI_DISPLAY_ROTATION_90:
1373. EntryMode.V=0x0008;
1374. break;
1375.
1376. case DDI_DISPLAY_ROTATION_180:
1377. EntryMode.V=0x068;
1378. break;
1379.
1380. case DDI_DISPLAY_ROTATION_270:
1381. EntryMode.V=0x00C8;
1382. break;
1383.
1384. default:
1385. ret = ERROR_DDI_DISPLAY_CONTROLLER_ROTATION;
1386. break;
1387. }
1388.
1389. if( !ret )
1390. {
1391. WriteDirect(CMD_MODE, 0x16); // Entry Mode
1392. WriteDirect(DATA_MODE, EntryMode.V);
1393. }
1394.
1395. return ret;
1396. }
1397.
1398. ////////////////////////////////////////////////////////////////////////////////
1399. //! \fn RtStatus_t ddi_display_controller_SendCommand(ddi_display_controller_CommandType_t eType, ...)
1400. //!
1401. //! \brief Sends the specified command to the controller
1402. //!
1403. //! \fntype Function
1404. //!
1405. //! \param[in] eType - Type of command to send
1406. //! \param[in] ... Variable argument list - The rest of the arguments are specific
1407. //! to the type of command is to be sent. Refer to
1408. //! ddi_display_controller.h for command types and their
1409. //! corresponding argument lists.
1410. //!
1411. //! \retval SUCCESS No error
1412. //!
1413. //! \retval ERROR_DDI_DISPLAY_CONTROLLER_COMMAND_UNSUPPORTED - This
1414. //! controller does not support the given command type
1415. //!
1416. //! \retval ERROR_DDI_DISPLAY_CONTROLLER_BITMAP_TYPE_UNSUPPORTED - This
1417. //! controller does not support the given bitmap color type
1418. //!
1419. //! \retval ERROR_DDI_DISPLAY_CONTROLLER_ROTATION - The specified rotation is
1420. //! not supported by the controller
1421. //!
1422. //! \retval ERROR_DDI_DISPLAY_PLACEMENT - There was an error placing the given
1423. //! region on the display that clipping could not compensate for.
1424. //!
1425. ////////////////////////////////////////////////////////////////////////////////
1426. RtStatus_t ddi_display_controller_SendCommand(ddi_display_controller_CommandType_t eType, ...)
1427. {
1428. RtStatus_t ret = SUCCESS;
1429. va_list valist;
1430. ddi_display_controller_CommandType_t eCommandType = eType;
1431.
1432. va_start(valist, eType);
1433.
1434. switch(eCommandType)
1435. {
1436. case DDI_DISPLAY_CONTROLLER_SET_REGION:
1437. {
1438. uint32_t u32XDst = va_arg(valist, uint32_t);
1439. uint32_t u32YDst = va_arg(valist, uint32_t);
1440. uint32_t *pu32Width = va_arg(valist, uint32_t *);
1441. uint32_t *pu32Height = va_arg(valist, uint32_t *);
1442. ddi_display_Rotation_t eRotation = (ddi_display_Rotation_t)va_arg(valist, ddi_display_Rotation_t);
1443. ret = SendControllerRegion(u32XDst, u32YDst, pu32Width, pu32Height, eRotation);
1444. }
1445. break;
1446. case DDI_DISPLAY_CONTROLLER_INIT:
1447. {
1448. gfx_BitmapTypeEnum_t eBitmapType = va_arg(valist, gfx_BitmapTypeEnum_t);
1449. uint32_t u32ScreenWidth = va_arg(valist, uint32_t);
1450. uint32_t u32ScreenHeight = va_arg(valist, uint32_t);
1451. InitPwmBacklight();
1452. // SetPwmBrightness(50);
1453. // SendControllerOutputEnable(true);
1454. SendControllerInitSeq(eBitmapType, u32ScreenWidth, u32ScreenHeight);
1455. }
1456. break;
1457. case DDI_DISPLAY_CONTROLLER_OUTPUT_ENABLE:
1458. SendControllerOutputEnable(va_arg(valist, bool));
1459. break;
1460. /*
1461. #ifdef RTOS_THREADX
1462. case DDI_DISPLAY_CONTROLLER_SET_VIDEO_MODE:
1463. SendControllerVideoMode(va_arg(valist, ddi_display_VideoMode_t));
1464. break;
1465. case DDI_DISPLAY_CONTROLLER_WAIT_FOR_VSYNC:
1466. ret = WaitForControllerVsync();
1467. break;
1468. #endif
1469. */
1470. // Contrast not supported by this controller. The Solomon Systech
1471. // engineers say that you need to adjust greyscale and all sorts of
1472. // voltages that can greatly impact the display's performance. There's
1473. // not any simple dedicated contrast register setting.
1474. // case DDI_DISPLAY_CONTROLLER_SET_CONTRAST:
1475. // SendControllerContrast(va_arg(valist, uint32_t));
1476. // break;
1477. case DDI_DISPLAY_CONTROLLER_SET_BRIGHTNESS:
1478. SetPwmBrightness(va_arg(valist, uint32_t));
1479. break;
1480. case DDI_DISPLAY_CONTROLLER_SET_ROTATION:
1481. {
1482. ddi_display_Rotation_t eRotation = va_arg(valist, ddi_display_Rotation_t);
1483. ret = SendControllerRotation(eRotation);
1484. }
1485. break;
1486. case DDI_DISPLAY_CONTROLLER_SET_RESOLUTION:
1487. {
1488. uint16_t u16Width = va_arg(valist, uint16_t);
1489.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -